Added read and write functions.