I'm not sure I get your requirement. Maybe it's:
* There is a text file with a bunch of strings / lines.
* The user enters a
string in the UI.
* You want to remove the user's string from the file?
You can't really update a text file in place. You pretty much have to read it modify the content and rewrite it. You can read it all into memory at once or read-modify-write a line at a time. Either way, here's a scheme I like:
* read original
* write temp
* rename original to backup
* rename temp to original
* erase backup
That gives you a safe copy of the file at all times just in case your program crashes in mid-flight.
Does that help?