How can the PHP code be modified to ensure each entry is saved on a new line in the file?

To ensure each entry is saved on a new line in the file, we can use the PHP function "\n" to insert a newline character after each entry is written to the file. This will create a new line for each entry, making the file more readable.

<?php
$data = "New entry to be saved\n";
$file = fopen("data.txt", "a");
fwrite($file, $data);
fclose($file);
?>