code: private ServerStatusMessage getNextMessage(BufferedReader reader)
              throws Exception {
  
          boolean messageStarted = false;
  
          String line = reader.readLine();
          while (line != null && !messageStarted) {
              if (line.equals(BEGIN_LINE)) {
                  messageStarted = true;
              } else {
                  line = reader.readLine();
              }
          }
  
          if (messageStarted) {
  
              // get and parse first two required lines
              ServerState state = ServerState.fromString(getNextLine(reader));
              Date time = ServerStatusMessage.stringToDate(getNextLine(reader));
              String detail = null;
  
              // read optional detail lines till END_LINE
              line = getNextLine(reader);
              if (!line.equals(END_LINE)) {
                  StringBuffer buf = new StringBuffer();
                  while (!line.equals(END_LINE)) {
                      buf.append(line + "\n");
                      line = getNextLine(reader);
                  }
                  detail = buf.toString();
              }
  
              return new ServerStatusMessage(state, time, detail);
          } else {
  
              return null;
          }
  
      }
docs: return the next message, or null if there are no more messages in the file