in reply to log file formatting

What are you using to view the file?

If it a regular text editor (vi, xemacs, or similar) then it should be seeing the newline (\n) that your script is writting.

If it an html viewer or something then you'll need to put the proper code for a new line. For an html viewer that would be the BR tag.

As mentioned above, if heaven forbid you're on an evil OS you might need to use \r or even \r\n instead of \n