Created `read_file` and `write_file` functions, and used them everywhere. Please rereview (unit tests pass).