added file_write function