Throw SystemError if fwrite fails.