pass file name to write file function