Haha, duplicate thread
I posted this in the other one, but you can also use sed to remove the whole line:
sed /rat/d test.txt
Edit: Oh! and I mentioned this in the other thread as well, but if you use the "-i" switch with sed, it will edit the file "in place" so you don't have to create a new one:
sed -i /rat/d test.txt
Edit: I keep forgetting details... Anyway, this will find anything that matches "rat" and delete the whole line. This might not be desirable if you have words in there like "scrat" or "ratatouille". You'll want to play with regular expressions if you need to get that level of detail.