The following code is a simple example. It opens the source file, reads line by line and eregi checks if words 'word1' and 'word2' exist. If so, will not put the lines into the destination file. Not sure if it is the best way but does work with limited punctuation for the words.
$file1 = fopen("textfile.txt", "r"); // original file
$file2 = fopen("newfile.txt", "w"); // new modified file
while(!feof($file1)) {
$line = fgets($file1, 1024);
if(!eregi("word1", $line) and !ereg("word2", $line)) {
fputs($file2, $line);
}
}