Rather than assume you know where the password file is, you should loop through fetches of getpwent. On some machines the password files may be in a binary format, available through nis, or otherwise not be where you think they are. Don't add an unnecessary assumption. :-)