title: How do I read a file line by line in VB Script?
body: <p>I have the following to read a file line by line:</p>
  
  <pre><code>wscript.echo "BEGIN"
  
  filePath = WScript.Arguments(0)
  filePath = "C:\Temp\vblist.txt"
  Set ObjFso = CreateObject("Scripting.FileSystemObject")
  Set ObjFile = ObjFso.OpenTextFile(filePath)
  StrData = ObjFile.ReadLine
  wscript.echo "END OF FIRST PART"
  
  Do Until StrData = EOF(ObjFile.ReadLine)
      wscript.echo StrData
      StrData = ObjFile.ReadLine
  Loop
  
  wscript.echo "END"
  </code></pre>
  
  <p>The <code>EOF()</code> function doesn't seem to work:</p>
  
  <pre><code>C:\Users\EGr\Documents\Scripts\VB&gt;cscript testloop.vbs ArgVal
  Microsoft (R) Windows Script Host Version 5.8
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  BEGIN
  END OF FIRST PART
  C:\Users\EGr\Documents\Scripts\VB\testloop.vbs(11, 1) Microsoft VBScript runti
  me error: Type mismatch: 'EOF'
  </code></pre>
  
  <p>I haven't programmed in VB before, but I'm trying to figure out loops so that I can modify a VB script I've been handed. I want to read a file line by line, and do something with each line. If I change the Do Until loop to <code>Do Until StrData = EOF</code>, it works but throws an error when it gets to the end of the file:</p>
  
  <pre><code>C:\Users\EGr\Documents\Scripts\VB&gt;cscript testloop.vbs ThisRANDOMValue
  Microsoft (R) Windows Script Host Version 5.8
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  BEGIN
  1
  END OF FIRST PART
  host1
  host2
  host3
  C:\Users\EGr\Documents\Scripts\VB\testloop.vbs(13, 2) Microsoft VBScript runti
  me error: Input past end of file
  </code></pre>
  
  <p>I feel like there is probably an easy solution, but I haven't been able to find it. I've tried a few other solutions I've found online, but haven't got as close as the above.</p>