How can the issue of missing line breaks in a CSV file generated by PHP be resolved?

Issue: The missing line breaks in a CSV file generated by PHP can be resolved by adding "\r\n" at the end of each line to ensure proper formatting.

<?php
$data = array(
    array('John', 'Doe', 'john.doe@example.com'),
    array('Jane', 'Smith', 'jane.smith@example.com')
);

$fp = fopen('data.csv', 'w');

foreach ($data as $fields) {
    fputcsv($fp, $fields);
    fwrite($fp, "\r\n");
}

fclose($fp);
?>