Adds custom error handling for EOF. Fixes #17