A bugfix for #969

The reference says ```IOError``` if the input file does not exist or cannot be read.

But I'm not sure if the problem is a file not found which makes the ```with``` fail for @yarikoptic in #969 .