wrote code for reading and writing to files.