Streamwriter returning Null Javascript

I’m having problems with Streamwriter. First off, Here is the way I’m getting the values for each line(I’m using Js) -

while (true) {

 for (i = 0; i <= 1; ++i){
 input = "";
     input = sr.ReadLine();
     forward = input;
     Debug.Log(forward);
     }

 for (i = 1; i <= 2; ++i){
 input2 = "";
     input = sr.ReadLine();
     left = input;
   Debug.Log(left);
     }

 for (i = 2; i <= 3; ++i){
 input3 = "";
     input = sr.ReadLine();
     right = input;
     Debug.Log(right);
     }

 for (i = 3; i <= 4; ++i){
 input4 = "";
     input = sr.ReadLine();
     backward = input;
     Debug.Log(backward);
     }


if (input == null) { break; }
 if (input2 == null) { break; }
  if (input3 == null) { break; }
   if (input4 == null) { break; }

Now for the problem. When ever I start the game, it loads all the values but then after the debug log shows that each value has been loaded. The last 3 turn null. What am I doing wrong?

Um, I think you are trying to read 4 values. Each of your for loops will execute twice, so that tells me you’ll try to read 8 values.