def METHOD_NAME(self, data):
    if data == '\n' and self.found:
        self.found = False
    else:
        if not self.pattern.search(data):
            self.stream.METHOD_NAME(data)
            self.stream.flush()
            if self.log_file:
                try:
                    with open(self.log_file, 'a', encoding='utf-8') as l:
                        l.METHOD_NAME(data)
                except:
                    pass
        else:
            # caught bad pattern
            self.found = True