public function getConfiguredWriter($fp, Configuration $config = null)
    {
        if(! $config) {
            $config = $this->config;
        }

        $writerName = $config->getOption(Configuration::OPT_WRITER);
        if(! $writerName) {
            throw new \Exception('Writer must be defined in config for getConfiguredWriter()');
        }

        $writer = $this->getWriterByName($fp, $writerName);
        $writer->setAutoCloseStream($config->getOption(Configuration::OPT_AUTO_CLOSE_STREAM, false));
        $writer->setConfig($config);
        return $writer;
    }