How do the entries in the text file get in the text file?

Are they from the listbox?

If so, then when you delete the item from the listbox, delete the entire text file, and just recreate it with the existing items in the listbox.