code: private void resizeWindowIfNecessary(int newSize) {
          try {
              int numberOfLinesToLoad = newSize - this.lineQueue.size();
              for (int i = 0; i < numberOfLinesToLoad; i++) {
                  String nextLine = getNextLine();
                  if (nextLine != null) {
                      lineQueue.addLast(nextLine);
                  } else {
                      throw new IndexOutOfBoundsException("End of stream has been reached!");
                  }
              }
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
      }
docs: Resizes the sliding window to the given size, if necessary.
  
  @param newSize the new size of the window (i.e. the number of lines in the
  window).