code: def pager(self, lines):
          try:
              line_count = 0
              if self._output_filename:
                  print(f"Output is also going to '{self.output_file}'")
                  self._output_file = open(self._output_filename, "a+")
              terminal_columns, terminal_lines = shutil.get_terminal_size(fallback=(80, 24))
              lines_left = terminal_lines
              for i, l in enumerate(lines, 1):
                  line_residue = 0
                  if self.line_numbers:
                      output_line = f"{i:<4} {l}"
                  else:
                      output_line = l
                  line_overflow = int(len(output_line) / terminal_columns)
                  if line_overflow:
                      line_residue = len(output_line) % terminal_columns
                  if line_overflow >= 1:
                      lines_left = lines_left - line_overflow
                  else:
                      lines_left = lines_left - 1
                  if line_residue > 1:
                      lines_left = lines_left - 1
                  print(output_line)
                  if self._output_file:
                      self._output_file.write(f"{l}\n")
                      self._output_file.flush()
                  if (lines_left - self.overlap - 1) <= 0:
                      if self.paginate:
                          print("Hit Return to continue (q or quit to exit)", end="")
                          user_input = input()
                          if user_input.lower().strip() in ["q", "quit", "exit"]:
                              break
                          terminal_columns, terminal_lines = shutil.get_terminal_size(fallback=(80, 24))
                          lines_left = terminal_lines
              if self._output_file:
                  self._output_file.close()
          except KeyboardInterrupt:
              print("ctrl-C...")
              if self._output_file:
                  self._output_file.close()