private function removeExistingLicense(SplFileInfo $file, array $tokens, $licenseIndex, $dryRun)
    {
        $this->log(sprintf('<fg=red>[-]</> Removing license header for <options=bold>%s</>', $file->getRealPath()));

        if (true === $dryRun) {
            return;
        }

        $content = $file->getContents();

        $removals = array();

        // ignore index 0 (this should always be <?php tag) and find all whitespace tokens before license
        for ($index = 1; $index <= $licenseIndex; $index++) {
            $token = $tokens[$index];

            if ($token[0] !== T_WHITESPACE && $token[0] !== T_COMMENT) {
                continue;
            }

            $startLineNumber = $token[2];
            $removalLength   = strlen($token[1]);

            // find start line in content
            $currentLineNumber = 1;
            $removalStart = 0;

            while ($currentLineNumber < $startLineNumber) {
                $removalStart = strpos($content, PHP_EOL, $removalStart) + strlen(PHP_EOL);
                $currentLineNumber++;
            }

            $removals[] = new TokenRemoval($removalStart, $removalLength);
        }

        $removalOffset = 0;

        /** @var $removal TokenRemoval */
        foreach ($removals as $removal) {
            $content = substr($content, 0, $removal->getStart() - $removalOffset) . substr($content, $removal->getEnd());

            $removalOffset += $removal->getLength();
        }

        file_put_contents($file->getRealPath(), $content);
    }