VBScript Question

Someone please tell me why this script never exits the Loop PLEASE!

On Error Resume Next

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim fso, f, s

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForReading, True)
Do While NOT f.AtEndOfStream
   s = f.readline
   wscript.Echo s
   f.Close
Loop
PackerlandAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
KJHDI12Connect With a Mentor Commented:

f.Close

should be afte

Loopr
0
 
_ys_Commented:
Swap the last two lines:

Loop
f.Close
0
 
EDDYKTCommented:
Also change ForReading to 1
0
 
EDDYKTCommented:
never mind
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.