# Arc script

**URL:** <https://community.cdata.com/t/arc-script/993>\
**Category:** CData Arc\
**Tags:** question, cdata-arc, arcscript\
**Created:** [January 10, 2025, 10:34am UTC](https://community.cdata.com/t/arc-script/993 "2025-01-10T10:34:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bala\_bk](https://avatars.discourse-cdn.com/v4/letter/b/f04885/32.png) [@bala\_bk](https://community.cdata.com/u/bala_bk)\
**Post date:** [January 10, 2025, 10:34am UTC](https://community.cdata.com/t/arc-script/993/1 "2025-01-10T10:34:16Z")

</div>

how to remove the first five lines in flat file using Arc script

---

<div class="post-metadata">

**Author:** ![Rohit](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/rohit/32/638_2.png) [@Rohit](https://community.cdata.com/u/Rohit)\
**Post date:** [January 10, 2025, 10:43am UTC](https://community.cdata.com/t/arc-script/993/2 "2025-01-10T10:43:56Z")

</div>

Hi @bala_bk,

You can use the `fileReadLine` operation in the Arc script to read the file line by line. By checking if the index value is greater than 5, you can then push the relevant data to the output.

Below is a sample script to remove the first 5 lines from a flat file:

\<arc:set attr=“file.file” value=“[filePath]” /\>  
\<arc:set attr=“output.data”\>  
&nbsp; \<arc:call op=“fileReadLine” in=“file” out=“line”\>  
&nbsp; &nbsp; \<arc:if exp=“[\_index] \> 5”\>[line.file:data]\n\</arc:if\>  
&nbsp; \</arc:call\>  
\</arc:set\>&nbsp;  
\<arc:push item=“output” /\>

Please refer to our documentation on fileReadLine for more information:&nbsp;[CData Arc - fileReadLine | Version 24.3.9159](https://cdn.cdata.com/help/AZK/mft/op_FileReadLine.html)

---

<div class="post-metadata">

**Author:** ![bala\_bk](https://avatars.discourse-cdn.com/v4/letter/b/f04885/32.png) [@bala\_bk](https://community.cdata.com/u/bala_bk)\
**Post date:** [January 10, 2025, 2:18pm UTC](https://community.cdata.com/t/arc-script/993/3 "2025-01-10T14:18:57Z")

</div>

How to remove the last&nbsp;line&nbsp;in flat file using Arc script ??

The below script is to add the “END” on the last line but I need to remove the END which is present in the last line of a Flat-file??

\<arc:set attr=“file.file” value=“[filepath]” /\>

\<arc:call op=“fileRead” item=“file”\>  
&nbsp; \<arc:set attr=“tmp.originalBody”\>[file.file:data]\</arc:set\>  
\</arc:call\>

\<arc:unset attr=“output.data”\>[tmp.originalBody]END\</arc:set\>  
\<arc:unset attr=“output.filename” value=“940\_[now()]” /\>  
\<arc:push item=“output” /\>
