I tries that but It would print the word to the data base about twenty or thirty times.

I tried moving around the foreach brackets but that didn't help. I had to take out the return codes because the search engine was not working with those in there. The first data base $data is used to print the results to and the second $data2 is for the key words and I need it to stop printing the same things over and over for both data bases.