make write function work on new files