code: public static void printRawLines(PrintWriter writer, String msg) {
          int nl;
          while ((nl = msg.indexOf('\n')) != -1) {
              writer.println(msg.substring(0, nl));
              msg = msg.substring(nl+1);
          }
          if (msg.length() != 0) writer.println(msg);
      }
docs: Print the text of a message, translating newlines appropriately
  for the platform.