I had the same arror but under different circumstances.
My script would work fine on the CLI but in a browswer it would fail with a blank page. The entire response was empty, the server would simply close the connection.
I was editing the scripts on my local machine and then FTPing the files to the server. Restarting the FTP service on the remote box solved it for me.