Change file write function