Both the code in the question and "solution" are wrong, even if you think it "works". If something works but you don't understand how, it does not work.
First of all, never use the class
ArrayList
it was rendered obsolete as early as of .NET Framework v.2.0, when generics were introduced. It wasn't formally parked
[Obsolete]
just because there is nothing wrong in using it through some legacy code. For new development, you need to use the class
System.Collections.Generics.List<>
. It won't require potentially unsafe element type casting.
Now, what you really need to obtain correctly split lines is the class
System.IO.File.ReadAllLines
:
http://msdn.microsoft.com/en-us/library/system.io.file.aspx[
^].
Not only your code is redundant, it's also non-portable. Please see:
http://en.wikipedia.org/wiki/End-of-line[
^].
—SA