Just for the hell of it, here's a PHP 4.4+ only inelegant hack:
Code:
<?php echo file_put_contents('file.new', str_replace("\n", "lolsox\n", file_get_contents('file')))?"Worked\n":"Didn't worked\n";?>
Really, though, everything above works in exactly the same way - find 'end of line' and replace (append) to. Semantically, it's slightly different, but doesn't matter.