read and write funcs.