added file reading and writing infrastructure