What are the potential pitfalls of using "\n" for line breaks in PHP text files, especially when dealing with different operating systems?

Using "\n" for line breaks in PHP text files can cause issues when the code is run on different operating systems. This is because different operating systems have different line break characters, such as "\r\n" for Windows and "\n" for Unix-based systems. To ensure cross-platform compatibility, it is recommended to use the PHP_EOL constant, which represents the correct line break character for the current operating system.

// Using PHP_EOL for line breaks to ensure cross-platform compatibility
$file = fopen("example.txt", "w");
fwrite($file, "Line 1" . PHP_EOL);
fwrite($file, "Line 2" . PHP_EOL);
fclose($file);