The way you've made your guestbook makes it very hard to delete old entries, because you would have to remove the lines from the beginning of the file. And since your data file is actually just a chunk of html, it's hard to get the script to count the entries accurately and determine which lines to remove.
The way the guestbook on my site works is when you submit an entry it saves the data to a text file in a simple format that I made up, which consists of entries that look like this:
<entry>
name::karl
age::15 (true!)
email::bad_goose@hotmail.com
comments::hey this is a guestbook entry blah blah
</entry>
Then I have a different script for viewing the guestbook, which opens that file, reads all that data into arrays, and then displays them by reading a different template file and applying the html formatting in it. That way it's easy to display entries in different ways and in different orders that they were submitted, because they are read into variables before being displayed.
In other words, the difference between your guestbook and mine is that yours creates the html formatting for entries when the entry is saved, whereas mine creates that each time the entries are displayed. I suggest you rewrite your guestbook and do it my way.