write file to openfile/closefile