change method to write file