I have the following test script:
It is best to use PHP_EOL
. This is cross-platform, so it automatically chooses the correct newline character(s) for the platform PHP is currently running on.
$stringData = "Floppy Jalopy" . PHP_EOL;
PHP Constants
Your code runs fine.
Use Notepad2 or Notepad++ if you're working on Windows. The built-in Notepad is unable to cope with Unix-style line endings.
. PHP_EOL; will work universally
If you want to open the file in Windows notepad, you must use Windows line breaks: \r\n