あれ、やっぱりだめだ。
textの内容によってはi2が16000以上の数字のまま無限ループになる。
どうして?

int i1;
int i2;
do
{
text = text.Replace("\n\n", "\n");
text = text.Replace(" ", " ");

i1 = text.IndexOf("\n\n");
i2 = text.IndexOf(" ");

} while (i1 != -1 || i2 != -1);