Fix EOF detection

Fixes issue with Ctrl-D having to be pressed twice when reading from
terminal.
Merge pull request #232 from nwellnhof/eof_detection

Fix EOF detection