I'm writing a "Move To Front" encoder that reads a file given then parses the file into a list. It works fine with the encoding, however it only works with files of only one line, I think the problem is in the while loop.

Here is the code:

```
while ((line = br.readLine()) !=
       null) // While the line file is not empty after reading a line from teh text file split the line into strings
{
  splitArray = line.split(" ");
}

for (int i = 0; i <= splitArray.length - 1;
     i++) // for every string in the array test if it exists already then output data accordinly
{
  if (FirstPass.contains(splitArray[i])) {
    System.out.println(FirstPass.lastIndexOf(splitArray[i]));
    FirstPass.addFirst(splitArray[i]);
    FirstPass.removeLastOccurrence(splitArray[i]);
  } else if (!FirstPass.contains(splitArray[i])) {
    FirstPass.addFirst(splitArray[i]);
    System.out.println("0 " + splitArray[i]);
  }
}

System.out.println(" ");
for (String S : FirstPass) {
  System.out.println(S);
}

```