write file_write function