in reply to formatting STDOUT

On a modern Apache server, you will need to flush the output data by setting $|=1 at the top of your script. This would probably work on other servers as well...