How to add some text in a certain row of a txt file?

Hello everyone,

I have a .txt file that I want to manipulate. I just need to add a word in the second row of the file. In this case, the first row is blank (and I do not want to remove it).

So we start from here:
And what I want to achieve is:

Thank you very much!

HI @EngAnalyst - Use Read Text File activity and store the output into a variable. Then use a String Manipulation to insert your text in between with start and end index of the the string. Once that’s done then use Write Text File activity and pass that variable to write into the text file.


Thanks but my concern is just about how to do the manipulation.
Thanks again

Create a String Array variable and assign this code - “Your Variable” is the output variable of Read Text File “YourVariable.Split({Environment.NewLine},StringSplitOptions.None)”

The above code will split the string and you want to insert the text between first and second line

Then assign the Your Variable = “YourVariable.Insert(YourStringArrayVariable(0).Count,” WORD")"

Then Write Text File using “Your Variable”


I just want to add a word at the end of a phrase. I think I didn’t explain myself well…

Yes, the above mentioned code will do that.

  1. Assign Activity :- YourStringArrayVariable = YourVariable.Split({Environment.NewLine},StringSplitOptions.None)

  2. Assign Acitivity :- YourVariable = “YourVariable.Insert(YourStringArrayVariable(0).Count,” WORD")"

  3. Write Text File using YourVariable

YourVariable is the output variable of Read Text File activity.


1 Like