code: def count_lines_in_file(self, fname=''):
          
          i = 0
          if fname == '':
              fname = self.fullname
          try:
              #with open(fname, encoding="utf8") as f:
              with codecs.open(fname, "r",encoding='utf8', errors='ignore') as f:    
                  for i, _ in enumerate(f):
                      pass
              return i + 1    
          except Exception as ex:
              print('cant count lines in file in "', fname, '":', str(ex))
              return 0
docs: you wont believe what this method does