added tests for reading and writing from closed files