You want to do something like the following:
- Open the old file for reading
- Open a new (temporary) file for writing
- Iterate over the lines in the old file (probably using a BufferedReader)
- For each line, check if it matches what you are supposed to remove
- If it matches, do nothing
- If it doesn't match, write it to the temporary file
- When done, close both files
- Delete the old file
- Rename the temporary file to the name of the original file
(I won't write the actual code, since this looks like homework, but feel free to post other questions on specific bits that you have trouble with)