add methods and a test for writing a file