using System;

namespace MyCompiler {
    class Program {
        public static void Main(string[] args) {
            var ss = new[]
            {
                "",
                "line",
                "line1\nline2",
                "line1\n\nline3",
                "line1\n\n\nline4",
                "line1\nline2\n\nline4\n\n\nline7"
            };
            foreach (var s in ss)
            {
                Console.WriteLine("==========");
                var s1 = s;
                while (true)
                {
                    var s2 = s1;
                    s1 = s1.Replace("\n\n", "\n");
                    if (s1 == s2)
                        break;
                }
                Console.WriteLine(s1);
            }
        }
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: