Need sourcecode for vb-script...

Hi!

Have a textfile that i need a vb-script file to do this:

Read textfile and find the text "Hittil" , when the text "Hittil" in the textfile is found.
It must insert needed blank lines befor "Hittil"....

Example textfile:

This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7 Hittil

Example textfile 2:

This is line 1
This is line 2
This is line 3
This is line 4
This is line 5 Hittil

Wanted result for tekstfile 2:
This is line 1
This is line 2
This is line 3
This is line 4


This is line 5 Hittil


So the script must count number of lines before it find "Hittil", and the insert needed blank lines.

Can please sombody give me the source for this vb-script ?

THANKS

Tor
LVL 2
team2005Asked:
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.

vinnyd79Commented:
Something like this?

Dim fso,fil,Line,fData
Set fso = CreateObject("Scripting.FileSystemObject")
Set fil = fso.OpenTextFile("C:\Test.txt",1)
While Not fil.AtEndOfStream
   Line = fil.ReadLine
   if Instr(Line,"Hittil") Then
      fData = fData & vbCrLf & vbCrLf  & vbCrLf & Line
   Else
      if fData = "" Then
            fData = Line
         Else
            fData = fData & vbcrlf & Line
         End if
   End if
Wend
fil.Close
Set fil = fso.OpenTextFile("C:\Test.txt",2)
fil.Write fData
fil.close
Set fil = Nothing
Set fso = Nothing
0

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
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.

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.