only write file if there are changes