added file read and write functions