i need to know how to find one line in a file and delete that line only.

like if i type "text" in a textfield then i click a button and it finds the line in a file where it says "text" and after that clears only that line.