Implementing writing to a file for testing