code: static String getSafeSystemNewline() {
      try {
        String unsafeNewline = System.getProperty("line.separator");
        if (unsafeNewline.matches(ALLOWED_NEWLINE_PATTERN)) {
          return unsafeNewline;
        }
      } catch (SecurityException e) {
        // Fall through to default value;
      }
      return "\n";
    }
docs: Returns the system newline separator avoiding any issues with security exceptions or
  "suspicious" values. The only allowed return values are "\n" (default), "\r" or "\r\n".