Your code has other syntax issues too, like Close, etc.
Can you share the entire script ?.