Qualify global functions consistently.
Use proper input file handle.
Exit shell upon receiving EOF on STDIN ("CTRL+D").

Closes #1.