'Main method for handling other methods.'

def process_tokens(self):

    line_count = 0
    with open(self.__file, 'r') as read_obj:
        with open(self.__write_to, 'wb') as write_obj:
            for line in read_obj:
                token = line.replace('\n', '')
                line_count += 1
                if ((line_count == 1) and (token != '\\{')):
                    msg = "\nInvalid    RTF:    document    doesn't    start    with    {\n"
                    raise self.__exception_handler, msg
                elif ((line_count == 2) and (token[0:4] != '\\rtf')):
                    msg = "\nInvalid    RTF:    document    doesn't    start    with    \\rtf    \n"
                    raise self.__exception_handler, msg
                the_index = token.find('\\    ')
                if ((token is not None) and (the_index > (-1))):
                    msg = ('\nInvalid    RTF:    token    "\\    "    not    valid.\nError    at    line    %d' % line_count)
                    raise self.__exception_handler, msg
                elif (token[:1] == '\\'):
                    try:
                        token.decode('us-ascii')
                    except UnicodeError as msg:
                        msg = ('\nInvalid    RTF:    Tokens    not    ascii    encoded.\n%s\nError    at    line    %d' % (str(msg), line_count))
                        raise self.__exception_handler, msg
                    line = self.process_cw(token)
                    if (line is not None):
                        write_obj.write(line)
                else:
                    fields = re.split(self.__utf_exp, token)
                    for field in fields:
                        if (not field):
                            continue
                        if (field[0:1] == '&'):
                            write_obj.write(('tx<ut<__________<%s\n' % field))
                        else:
                            write_obj.write(('tx<nu<__________<%s\n' % field))
    if (not line_count):
        msg = '\nInvalid    RTF:    file    appears    to    be    empty.\n'
        raise self.__exception_handler, msg
    copy_obj = copy.Copy(bug_handler=self.__bug_handler)
    if self.__copy:
        copy_obj.copy_file(self.__write_to, 'processed_tokens.data')
    copy_obj.rename(self.__write_to, self.__file)
    os.remove(self.__write_to)
    bad_brackets = self.__check_brackets(self.__file)
    if bad_brackets:
        msg = '\nInvalid    RTF:    document    does    not    have    matching    brackets.\n'
        raise self.__exception_handler, msg
    else:
        return self.__return_code
