public function getSortedFile($sort = true)
    {
        if (!$this->tokens->valid()) {
            $this->logger->info('File is empty.');
        }
        while ($this->tokens->valid()) {
            $this->logger->info('parsing next block');
            $this->parseNextBlock();
        }
        if ($sort) {
            ksort($this->var_blocks);
        }
        $this->var_blocks = array_values($this->var_blocks);
        $blocks = array_merge($this->empty_blocks, $this->var_blocks, $this->end_blocks);

        return implode('', $blocks);
    }