ReadAllLines does remove all newlines, but WriteAllLines puts them all back!
Instead try this:
string inFile = Class1.filename;
string outFile = Class1.filename;
var contents = File.ReadAllLines(inFile);
Array.Sort(contents);
File.WriteAllText(outFile, string.Concat(contents));