I have a problem with this code in Safari (in Firefox and Chrome it works)
When I load the page, in the file created rows are duplicated. If you reload the page without closing the browser tab the script works well.
I attach a video to better understand
$fileName = 'test.txt';
$d = date("d/m/Y - H:i:s");
echo $d . "<br>
";
echo '------------------------------------------' . "<br>
";
file_put_contents($fileName, $d . PHP_EOL, FILE_APPEND);
$lines = file($fileName);
foreach($lines as $lineNum => $line) {
echo "Line #" . ++$lineNum . " : " . $line . "<br />
";
}