Here is some code that demonstrates the problem. I added some Console.WriteLine() to print out what is in the variables during and after the loop. (here is a fiddle)
using System;
using System.IO;
public class Program
{
const string _textFile = "This is the first line in the file\n"
+ "This is the second line in the file\n"
+ "This is the third line in the file\n";
public static void Main()
{
var utf8 = System.Text.Encoding.UTF8.GetBytes(_textFile);
var memoryStream = new MemoryStream(utf8);
memoryStream.Position = 0;
string wholeLine;
string[] optionsArray;
using (var inOFile = new StreamReader(memoryStream))
{
var count = 0;
while (!inOFile.EndOfStream)
{
wholeLine = inOFile.ReadLine();
optionsArray = wholeLine.Split('\n');
Console.WriteLine("Reading Line {0}", ++count);
Console.WriteLine("\tWhole: '{0}'", wholeLine);
Console.WriteLine("\tSplit: '{0}'", string.Join("', '", optionsArray));
Console.WriteLine()
}
Console.WriteLine("Final Options Array: {0}", string.Join(" | ", optionsArray));
}
}
}
The output of this program is:
Reading Line 1
Whole: 'This is the first line in the file'
Split: 'This is the first line in the file'
Reading Line 2
Whole: 'This is the second line in the file'
Split: 'This is the second line in the file'
Reading Line 3
Whole: 'This is the third line in the file'
Split: 'This is the third line in the file'
Final Options Array: This is the third line in the file
Notice how optionsArray only contains one item in it? And it's exact copy of wholeLine? That's because the ReadLine() function removes all the line breaks in the data. .Split('\n') won't be able to split anything.
If I change the split character to a space, then I get this:
Reading Line 1
Whole: 'This is the first line in the file'
Split: 'This', 'is', 'the', 'first', 'line', 'in', 'the', 'file'
Reading Line 2
Whole: 'This is the second line in the file'
Split: 'This', 'is', 'the', 'second', 'line', 'in', 'the', 'file'
Reading Line 3
Whole: 'This is the third line in the file'
Split: 'This', 'is', 'the', 'third', 'line', 'in', 'the', 'file'
Final Options Array: This | is | the | third | line | in | the | file
In this case, each line is split into separate words because they are separated by a space ' '. But even if I change the splitting, optionsArray only contains the last line in the file. Your while loop is written to read the entire file, but since you never do anything to collect the results of the split operating, the rest of your code won't do anything.