title: Exception using Rx and Await to accomplish reading file line by line async
body: <p>I am learning to use RX and tried this sample. But could not fix the exception that happens in the highlighted while statement - <em>while(!f.EndofStream)</em></p>
  
  <p>I want to read a huge file - line by line - and for every line of data - I want to do some processing in a different thread (so I used ObserverOn)
  I want the whole thing async. I want to use ReadLineAsync since it returns TASK and so I can convert that to Observables and subscribe to it. </p>
  
  <p>I guess the task thread which I create first, gets in between the Rx threads. But even if I use Observe and Subscribe using the currentThread, I still cannot stop the exception. Wonder how I do accomplish this neatly Aysnc with Rx.</p>
  
  <p>Wondering if the whole thing could be done even simpler ?</p>
  
  <pre><code>    static void Main(string[] args)
      {
          RxWrapper.ReadFileWithRxAsync();
          Console.WriteLine("this should be called even before the file read begins");
          Console.ReadLine();
      }
  
      public static async Task ReadFileWithRxAsync()
      {
          Task t = Task.Run(() =&gt; ReadFileWithRx());
          await t;
      }
  
  
      public static void ReadFileWithRx()
      {
          string file = @"C:\FileWithLongListOfNames.txt";
          using (StreamReader f = File.OpenText(file))
          {
              string line = string.Empty;
              bool continueRead = true;
  
              ***while (!f.EndOfStream)***
              {
                  f.ReadLineAsync()
                         .ToObservable()
                         .ObserveOn(Scheduler.Default)
                         .Subscribe(t =&gt;
                             {
                                 Console.WriteLine("custom code to manipulate every line data");
                             });
              }
  
          }
      }
  </code></pre>