public String getNextLineGroup() { StringBuffer sb = new StringBuffer(); String line; while (true) { try { line = reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } // System.out.println ("LineGroupIterator: got line: "+line); if (line == null) { break; } else if (!line.isEmpty()) { sb.append(line); sb.append('\n'); break; } } if (sb.length() == 0) return null; else return sb.toString(); }