Implemented writing to files.