No offense

I'm saying you're using an inefficient method because you're doing a /while on each line in the file whereas the ,w, parameter of $read already do this itself.
But I agree that the way you're checking for a match isn't the same as $read(,w,), I should not have compared the two situation sorry.