# Read Text File : iterating over File Contents

**URL:** https://www.finalbuilder.com/forums/t/read-text-file-iterating-over-file-contents/2262
**Category:** Discussion
**Created:** [March 19, 2014, 9:48am UTC](https://www.finalbuilder.com/forums/t/read-text-file-iterating-over-file-contents/2262 "2014-03-19T09:48:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![davestiff](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@davestiff](https://www.finalbuilder.com/forums/u/davestiff)
#### Post date: [March 19, 2014, 9:48am UTC](https://www.finalbuilder.com/forums/t/read-text-file-iterating-over-file-contents/2262/1 "2014-03-19T09:48:00Z")

</div>

Hello,  
  
is there a way to iterate over the file contents of the Read Text File action? Or do I need to use the OnReadLine event?  
  
I was hoping to, in a loop, read each line into a variable and then append some text, with the variable contents, using the Write To Text File action.  
  
i.e.  
&nbsp;&nbsp;&nbsp; Read Text File (into variable FileContents)  
&nbsp;&nbsp;&nbsp; Loop through each line of FileContents  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write To Text File "some text’ + line  
  
Thanks,  
Dave

---

<div class="post-metadata">

### Author: ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)
#### Post date: [March 20, 2014, 12:05pm UTC](https://www.finalbuilder.com/forums/t/read-text-file-iterating-over-file-contents/2262/2 "2014-03-20T12:05:11Z")

</div>

Hi Dave,&nbsp;  
  
You could use a File Contents Iterator, with then contains a String Replace, or Variable Set action followed by a Write To Text File which appends to an output file. &nbsp;I have attached an example project.&nbsp;  
  
[Read Text File - iterating over File Contents.zip](https://www.finalbuilder.com/Portals/0/Users/144/12/13712/Read%20Text%20File%20-%20iterating%20over%20File%20Contents.zip)

---

<div class="post-metadata">

### Author: ![davestiff](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@davestiff](https://www.finalbuilder.com/forums/u/davestiff)
#### Post date: [March 21, 2014, 2:30am UTC](https://www.finalbuilder.com/forums/t/read-text-file-iterating-over-file-contents/2262/3 "2014-03-21T02:30:32Z")

</div>

Thanks Jason!  
  
I wasn’t aware of this action.  
  
Dave
