How can the code be modified to handle cases where no entry is present in the guestbook file?

When no entry is present in the guestbook file, the code should check if the file exists before trying to read from it. If the file does not exist, the code can display a message indicating that the guestbook is empty.

$guestbookFile = 'guestbook.txt';

if (file_exists($guestbookFile)) {
    $entries = file($guestbookFile);
    
    if (!empty($entries)) {
        foreach ($entries as $entry) {
            echo $entry . "<br>";
        }
    } else {
        echo "Guestbook is empty.";
    }
} else {
    echo "Guestbook file not found.";
}