The loop would have aborted if the first pattern didn't match. This loop construct should do the trick. (Untested)