add functionality to write to new file and udpate file