while (fin.hasNextLine()) { line = fin.nextLine(); if (line.equalsIgnoreCase("//---ENDH---//")) { break; } else { lines.add(line); } }