in reply to File input not working properly?

Following up on what hipowls said, you might want to load the passwords into a hash (keyed on username) before you prompt the user.

That way, if you later change your progam to give the user (say) three chances to specify the password, you won't have to read through the file three time.