As grep suggested, you should look into the next and last flow controllers. Also, remember that once you find the error string once, you do not need to search through the rest of the file.
FYI, you need only one other statement in your existing code to accomplish your goal. ;)
Amel - f.k.a. - kel
Comment on Re: A single action from one or more items searched for