code: private static int countNewLines(char[] ch, int start, int length) {
          int newLineCount = 0;
          // quite reliable, since only Commodore 8-bit machines, TRS-80, Apple II family, Mac OS up to version 9 and OS-9
          // use only '\r'
          for (int i = start; i < length; i++) {
              newLineCount = newLineCount +  ((ch[i] == '\n') ? 1 : 0);
          }
          return newLineCount;
      }
docs: Count the number of new lines
  
  @param ch
  @param start
  @param length