It's not possible to see what "filename" is, from the script, but are you sure this location is writable when you run via PBS?
When you run via PBS, such errors are not always caught, and you have to kill the job manually. Check if there are any error messages in the .o file, after you kill it, that should give you an indication.
Not that it matters for this problem, but why 10.8.2? Looking at your email address, I would think you have access to 11.2. Lots and lots of things change, not least performance, plus some bugs.