How can PHP be used to read and write data from a text file while preserving line breaks?

When reading and writing data from a text file in PHP, it's important to preserve line breaks to maintain the formatting of the text. To achieve this, you can use the `file_get_contents()` function to read the file content while preserving line breaks, and the `file_put_contents()` function to write data back to the file without altering the line breaks.

// Read data from a text file while preserving line breaks
$fileContent = file_get_contents('example.txt');

// Modify the data as needed
$newData = "New line added\n" . $fileContent;

// Write data back to the text file while preserving line breaks
file_put_contents('example.txt', $newData);