public function writeRow(iterable $row): void
    {
        $str = Csv::dump($row, $this->delimiter, $this->enclosure, $this->escape);

        try {
            $written = $this->stream->write($str);
        } catch (\Throwable $e) {
            throw new \RuntimeException('Failed to write CSV row.', 0, $e);
        }

        if (strlen($str) !== $written) {
            throw new \RuntimeException('Failed to write CSV row.');
        }
    }