CPython compatibility: raise an error for operations on a closed file descriptor

In CPython any operations on a file that has been closed already reaises
a ValueError with message "I/O operation on closed file"