Check ftell() result for error code before using it.

`ftell()` can fail and return `-1` which would cause subtle errors if this value is used in the later code. Not sure "read error" is the right enum value for this cases but that's the best I could find.