Thank you very much Wilku!! That took care of the problem.
The program is now running correctly. While I have your attention let me run this one by you. I have been trying to make a change to the else statement that I have not been able to make work.
Right now, the script rights a line of text to the output2.txt file for each keyword that is not found in the file. In the else statement I would like to have it count the number of times the stristr() function is returned false. If the counter ever is equal to the number of keywords I would just like to write "The $file is clean."
Here is the code again for you:
$key = file("changes.txt");
$file = file("sqrs2.txt");
$result = count($key);
foreach ($file as $files) {
$files = trim($files);
$filecontents = file_get_contents($files);
foreach ($key as $keys) {
$keys = trim($keys);
if (stristr($filecontents, $keys)) {
$content = $keys . " was found in file " . $files . "\r\n";
$filec = fopen("output1.txt", "a+");
fwrite($filec, $content);
fclose($filec); }
else {
$content = $keys . " was not found in file " . $files . "\r\n";
$filec = fopen("output2.txt", "a+");
fwrite($filec, $content);
fclose($filec); } } }
Again thanks in advance for everyone's help!!!
KrisG.