private static boolean hasTrailingLineBreak(StringBuilder sb) {
        for(int i=sb.length()-1; i>=0; i--) {
          if (sb.charAt(i) == '\n') return true;
          if (!Character.isWhitespace(sb.charAt(i))) return false;
        }
        return false;
      }
private static boolean hasTrailingLineBreak(StringBuilder sb)