public function push($document)
    {
        $this->initialize();
        $this->currentPosition++;

        if (isset($this->metadata['count']) && $this->currentPosition > $this->metadata['count']) {
            throw new \OverflowException(
                sprintf('This writer was set up to write %d documents, got more.', $this->metadata['count'])
            );
        }

        fwrite($this->handle, ",\n");
        fwrite($this->handle, json_encode($document));

        if (isset($this->metadata['count']) && $this->currentPosition == $this->metadata['count']) {
            $this->finalize();
        }
    }