Working with Text files

1) Creating a Flat File:
set objfso = Createobject("Scripting.filesystemobject")
objfso.createtextfile("D:\testing.txt")


2) Check for existence of text file, if present delete it:
strdir = ("F:\Testing.txt")
set objfso = createobject("Scripting.filesystemobject")
if objfso.fileexists(strdir) = false Then
wscript.echo "Text file Not present" & Vbnewline & "Created now"
set txtfile = objfso.createtextfile("F:\Testing.txt")
else
objfso.deletefile("F:\Testing.txt")
wscript.echo "Present " &vbnewline &"But Text file deleted"
End if


3) Read content line by line in a text file:
Note: Initially create text file you want to read text from...
strdir = ("F:\test.txt")
set objfso = createobject("Scripting.filesystemobject")
set objfile = objfso.opentextfile(strdir)
Do Until objfile.AtEndOfStream
strtext = objfile.readline
wscript.echo (Strtext)
Loop