'Keep adding lines to our internal buffer until done_reading(self.buffer)
is true or EOF has been reached or we have desired_size bytes in the buffer.
If desired_size < 0, we are never satisfied until we reach EOF. If done_reading
is not supplied, it is not consulted.
If desired_size < 0, returns the length of the internal buffer. Otherwise,
returns desired_size.'

def __get_lines(self, desired_size, done_reading=(lambda buffer: False)):

    while ((not done_reading(self.buffer)) and ((desired_size < 0) or (len(self.buffer) < desired_size))):
        try:
            self.__get_line()
        except (EOFError, KeyboardInterrupt):
            desired_size = len(self.buffer)
    if (desired_size < 0):
        return len(self.buffer)
    else:
        return desired_size
