Overriding write function