code: public Collection<String> collect(Collection<String> result) throws IOException {
          String line;
  
          while (true) {
              line = next();
              if (line == null) {
                  close();
                  return result;
              }
              result.add(line);
          }
      }
docs: Also closes the LineReader.