Finger and error handling

I have this segment of code :

cmd = "finger -m " $1 " 2>/dev/null | head -1"
cmd | getline userinfo
close(cmd)

Sometimes finger returns no such user when given a user id.
With the redirection to the default trash file i am getting rid of any screen "finger:no such user" messages.
I also want to check if a user exists or not cause when a user does not exist userinfo keeps the previous result of finger, that means the last user that existed, and messes up my code.

Hello again, beatblaster666:

Why not just set userinfo to an empty string before each getline call? If it's still empty after the call, the user does not exist.

Regards,
Alister

Great idea, pfff i think i am a bit silly or tired from all those projects running at the same time. Thanks a lot mate.