"Input past end of file" error occurs during do loop

In a Do loop, I get an "input past end of file"  Here is the code:

1        Do
2            Line Input #1, strLine
3            strLine = Replace(strLine, strToBeReplaced, strReplacement)
4            Print #2, strLine
5        Loop Until EOF(1)

The error happens after the output is complete and it happens at line 2... "Line Input #1, strLine".  I don't understand why I would get an "input past end of file error" when I am using "Loop Until EOF".  Any ideas?

Thanks for the help!
LVL 5
bpl5000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amit_gCommented:
Do Until EOF(1)
    Line Input #1, strLine
    strLine = Replace(strLine, strToBeReplaced, strReplacement)
    Print #2, strLine
Loop

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
(just a matter of preference here)

While Not EOF(1)
    Line Input #1, strLine
    strLine = Replace(strLine, strToBeReplaced, strReplacement)
    Print #2, strLine
Wend
bpl5000Author Commented:
Ok, I realized that the reason it wasn't working is because the last file that it was opening for input was empty.  Anyway, both solutions above will solve the problem.

Thanks for the help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.