Add implementation for file write function