in reply to searching a file

It'll always fail unless the username in question is on the first line because that's what you've written. You want to look at all the lines, but if any line doesn't match you're exiting. What you want to do is last out of the while loop if you find a match and to use a flag in a conditional after the while loop's done.