Replace word in text file line1 only

I want to replace word in text file line1 only.

Example
Now : H|CODE|AMOUNT (line1)
I want to : H|CODE|ID|AMOUNT|SUMMARY

Please guide me about it.

Read the text, get it in a string,
Assign string like this STR1= STR.Replace(“H|CODE|AMOUNT”,“H|CODE|ID|AMOUNT|SUMMARY”)

then write it to text and save

This will replace “H|CODE|AMOUNT” even if it is in second line or anywhere, if there are too many of this we need to follow different method

This will replace “H|CODE|AMOUNT” even if it is in second line or anywhere, if there are too many of this we need to follow different method

1 Like

Kindly Mark it as solution if it works for you

Hi,
You can follow the below steps
Step-1: take one variable NewData =""
Step-2: Get text from existing text file and save in a variable - ExistedData = (get data with Read Text)
Step-3: Cocatinate the Variables - WriteNewData = NewData + ExistedData //Strings only
Step-4: Now Write the WriteNewData in existing text file

I wish it works