Another possible option would be to not pass file objects to `read_*` and `write_*`, but instead only pass paths, and then have the read/write function take care of the opening on its own (perhaps with a `gzip=True` flag if you want one read/write function to support both regular and gzipped files).