I wrote a program to generate large .SQL files for quickly populating very large databases. I scripted it in PHP. When I started coding I was using fopen()
Is it possible that your script is taking too long to execute and has timed out?
Alternatively, is it possible that you're reaching your memory limits within the script?