Can you confirm that when you start it out of an empty folder with no files except for the script, it still crashes? Can you then upload that script? I can look into it, maybe I see the reason of the problem.