Use a test output file for reading and writing test.  Delete the file at the end of the test for a clean test environment.