This example code shows how you can use the StreamReader class to read an write standard text files. The code below can be used as a basis for reading lines from one file, processing them and then writing them back out to another file.
I have used this code as a base for processing CSV, HTML and XML files.
On Error GoTo ErrorHandler
Dim oRead As System.IO.StreamReader
Dim oWrite As System.IO.StreamWriter
Dim strLine
Dim intLineCounter
intLineCounter = 0
oRead = IO.File.OpenText("input.txt")
oWrite = IO.File.CreateText("output.txt")
Do While oRead.Peek() <> -1
strLine = oRead.ReadLine
' Process or modify the strLine variable here
' before it is written to the output file
oWrite.WriteLine(strLine)
intTotalCounter = intTotalCounter + 1
Loop
oWrite.Close() ' Close output file
oRead.Close() ' Close input file
Exit Sub
ErrorHandler:
msgbox("There was an error!")