Please post general scripting issues on the Scripting forum. I’ll move your post there.
Also, when posting code, please use code-tags and not plain-text This also gives line numbers so that it’s easier to see the exact line rather than trying to count lines of plain-text. You can edit your post to include these.
Thanks.