When copy/pasting scripts from this forum or elsewhere to TextEdit, make sure you are saving your file as "Plain Text" (you can change this in TextEdit's prefs). Saving your script in "Rich Text Format" (RTF) will cause an error upon invoking the script from AE, even if your file looks normal when opened in TextEdit.