def METHOD_NAME(self, tokensource, outfile):
    self._write_lineno(outfile)
    for ttype, value in tokensource:
        color = self.colorscheme.get(ttype)
        while color is None:
            ttype = ttype[:-1]
            color = self.colorscheme.get(ttype)
        if color:
            color = color[self.darkbg]
            spl = value.split('\n')
            for line in spl[:-1]:
                if line:
                    outfile.write(ircformat(color, line))
                outfile.write('\n')
                self._write_lineno(outfile)
            if spl[-1]:
                outfile.write(ircformat(color, spl[-1]))
        else:
            outfile.write(value)