Factor out a function for reading a password file.
Factor out querying into a separate function.