Use the constant PHP_EOL to get the right character no matter the platform.
http://us3.php.net/manual/en/reserved.constants.php
A simple usage example:
<?php
$data = 'First line' . PHP_EOL .
'Second line' . PHP_EOL .
'Third line';
file_put_contents("filename.txt", $data);
?>