Fix warnings: ignoring return value of ‘write’, declared with attribute warn_unused_result