add test for writing to an existing file