How can you improve the syntax and functionality of a PHP script that reads and appends content to a text file?

The issue with the current PHP script that reads and appends content to a text file can be improved by using the file_put_contents function with the FILE_APPEND flag to append content to the file. This method simplifies the code and ensures that the content is appended to the file without the need for opening and closing the file manually.

$file = 'example.txt';
$content = "New content to append";

file_put_contents($file, $content . PHP_EOL, FILE_APPEND);