public static string TrimOneTrailingNewline(string s) { if (s.EndsWith("\r\n")) s = s.Substring(0, s.Length - 2); else if (s.EndsWith("\n")) s = s.Substring(0, s.Length - 1); return s; }