I came accross the same problem, what it was, is the file I was trying to run the script on was too big for my memory to take in all at once, i don't know how to divide the use of the system memory, iif possible, but When I split the file into half, or actually 5 pieces in my case, it worked fine, My code was only about 8 line long, and I was getting the same error, that should tell you that the length of your code doesn't produce the error, but what it's doing and with how big of a file,