You can't actually delete anything from a text file. You need to read the existing data in and then write the new data out. If you use a temporary file then you can read and write one record at a time, then move the temp file to overwrite the original. Otherwise, you would need to read the records into some sort of collection, remove the records to be deleted and then write the collection back out to the file.