update read and write to file method