public function write(iterable $data, ?array $headers = null): void
    {
        $this->assertAttached();

        $this->begin($headers);

        foreach ($data as $element) {
            $this->writeElement($element);
        }

        $this->end();
    }