Double check EOF when parsing so that streams don't hang

I'm not sure if this is the best way to check the EOF on a stream, but it works for me. See #14.