That will produce the same scenario that he previously had. The issue because the EOL (end of line) character used. Which varies by operating system. Windows, Mac, and Linux all use different EOL. It is usually safe to use \r
, and you can use PHP_EOL if you do not need to transfer your file between different operating systems (otherwise the PHP_EOL will be different on each system, so it might not read back the same).
Guys, for most file I/O scenarios [fphp]file_get_contents[/fphp] and [fphp]file_put_contents[/fphp] will do the job. [fphp]fopen[/fphp] and the related functions used to be the only way to do this sort of things, these days they really are just for situations where the size of the file makes loading it into memory impractical.