What are the best practices for handling file content in PHP, particularly when reading and writing data with line breaks?

When handling file content in PHP, particularly when reading and writing data with line breaks, it is important to use the correct file handling functions and consider the platform-specific line endings. To ensure consistent handling of line breaks, you can use the `fgets()` function to read a file line by line and the `fwrite()` function to write data with appropriate line endings.

// Reading a file line by line
$file = fopen("example.txt", "r");
while(!feof($file)) {
    $line = fgets($file);
    // Process the line here
}
fclose($file);

// Writing data with line breaks
$file = fopen("example.txt", "w");
$data = "Line 1\nLine 2\nLine 3\n";
fwrite($file, $data);
fclose($file);