move file creation to write action