You need to add the end-of-line characters after each line. The only problem is that these characters are system-dependent:
http://en.wikipedia.org/wiki/End-of-line[
^].
PHP has the predefined constant
PHP_OEL
, available since PHP 4.3.10 and PHP 5.0.2:
http://www.php.net/manual/en/reserved.constants.php[
^].
Depending on the OS, it will take the value of '\r\n', 'r' or '\n'; the constant will guarantee you use correct value for each OS.
—SA