code: private long readLines(final RandomAccessFile reader) throws IOException {
          final ByteArrayOutputStream lineBuf = new ByteArrayOutputStream(64);
          long pos = reader.getFilePointer();
          long rePos = pos; // position to re-read
          int num;
          boolean seenCR = false;
          // FIXME replace -1 with EOF when we're merging back into commons-io
          while ((num = reader.read(this.inbuf)) != -1) {
              for (int i = 0; i < num; i++) {
                  final byte ch = this.inbuf[i];
                  switch (ch) {
                      case '\n':
                          seenCR = false; // swallow CR before LF
                          this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
                          lineBuf.reset();
                          rePos = pos + i + 1;
                          break;
                      case '\r':
                          if (seenCR) {
                              lineBuf.write('\r');
                          }
                          seenCR = true;
                          break;
                      default:
                          if (seenCR) {
                              seenCR = false; // swallow final CR
                              this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
                              lineBuf.reset();
                              rePos = pos + i + 1;
                          }
                          lineBuf.write(ch);
                  }
              }
              pos = reader.getFilePointer();
          }
          IOUtils.closeQuietly(lineBuf); // not strictly necessary
          reader.seek(rePos); // Ensure we can re-read if necessary
          return rePos;
      }
docs: Read new lines.
  
  @param reader
  The file to read
  @return The new position after the lines have been read
  @throws java.io.IOException
  if an I/O error occurs.