Your code is fine... I just ran it on my machine and it worked perfectly without my changing anything. I suspect your problem is in your pass file... mine looked like this:
...and that's it. (The \t's are actual tabs... I've just put them in like this so you can see them.) Are you running the CGI on a Windows webserver or a Unix server? If you're creating your password file in Windows and uploading it to a Unix server without changing the line endings you'll have problems.
Hope this helps a little. Good luck!