title: Is it possible to give a shell input after reading a blank line in an Excel macro?
body: <p>I would like to query a MongoDB database multiple times through the shell</p>
  <p>When the output of a query is blank (because it doesn't exist in the database), I cannot execute another command through that same shell instance. Why is this and how to solve it?</p>
  <pre class="lang-vb prettyprint-override"><code>Dim wsh As New WshShell
  Dim proc As WshExec
  Dim i As Integer
  Dim result As String
  
  Set proc = wsh.Exec(&quot;mongo&quot;)
  proc.StdIn.WriteLine &quot;use mydb&quot;
  
  For i = 1 To 4
      If i = 3 Then
          proc.StdIn.WriteLine &quot;db.mycollection.find({'field': 'something non-existent'})&quot;
      Else
          proc.StdIn.WriteLine &quot;db.mycollection.find({'field': '&quot; &amp; i &amp; &quot;'})&quot;
      End If
      result = proc.StdOut.ReadLine
      Debug.Print i
      Debug.Print result
  Next i
  
  proc.StdIn.WriteLine &quot;quit()&quot;
  </code></pre>
  <p>Export:</p>
  <pre><code>1
  {something}
  2
  {something}
  3
  
  4
  
  </code></pre>
  <p>For iteration 3 and 4 I get a blank line and the shell window doesn't close at the end.<br />
  If I remove the if statement (so that query does find something), every iteration shows a result and the shell closes at the end.</p>