You need to change your logic such that the "does not match" message is printed AFTER the WHILE loop completes.
This means, you need a flag inside the while loop that determines whether or not a match was found.
Typically, this would be something like a $match_count, which initializes to zero, and is incremented on each match.
This counter could also be used to exit the loop early, if a match is found (using the 'last' verb).
At the end of the loop, if it is still zero, you print the message.
"By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."