public function render($file, $id = '')
    {
        if (empty($id) === true) {
            $id = uniqid();
        }

        $this->init($id, $file);

        $stream = $this->getStream();

        while ($stream->eof() === false) {

            try {
                $char = $stream->read(1);
                $this->beforeCharReading($char);

                switch ($this->getState()) {
                    case self::RUNNING:
                        $this->runningState();
                    break;

                    case self::IN_ATRULE:
                        $this->inAtRuleState();
                    break;

                    case self::IN_ATRULESTRING:
                        $this->inAtRuleStringState();
                    break;

                    case self::IN_SELECTOR:
                        $this->inSelectorState();
                    break;

                    case self::IN_CLASSBODY:
                        $this->inClassbodyState();
                    break;

                    case self::IN_MAINCOMMENT:
                        $this->inMainCommentState();
                    break;

                    case self::IN_CLASSSTRING:
                        $this->inClassStringState();
                    break;

                    case self::IN_CLASSCOMMENT:
                        $this->inClassCommentState();
                    break;

                    case self::IN_ATRULEBODY:
                        $this->inAtRuleBodyState();
                    break;
                }

                $this->afterCharReading($char);
            } catch (MemoryStreamException $e) {
                $stream->close();
                $msg = "An unexpected error occured while reading the CSS file '${file}'.";
                throw new RenderingException($msg, RenderingException::RUNTIME, $e);
            }
        }

        $stream->close();

        return $this->getOutput();
    }