Hi,
I want to edit the file in the following way

My Sample File:

101 273970116 2719674681506161941D094101METABANK               WAVECREST                      
5220Taxi Charger    Micro Deposit - Cr  A271967468WEBP2P             150616   1273970110000001
6220110000156534057672       0000000007GreenGrP2C386daTest User             S 0273970110000001
6220110000156534057672       0000000005ClarkGrP2C386dcTest User             S 0273970110000002
82200000020002200002000000000000000000000012A271967468                         273970110000001
9000001000001000000020002200002000000000000000000000012                                       
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

In the above file, wherever if i find the row starting with number '6' , i need to insert the line after that row and write some thing as

ex : 798R03073972187779351 05190376011000015 044000024265158

Finally my output file should be as below:

101 273970116 2719674681506161941D094101METABANK               WAVECREST                      
5220Taxi Charger    Micro Deposit - Cr  A271967468WEBP2P             150616   1273970110000001
6220110000156534057672       0000000007ClarkGrP2C386daTest User             S 0273970110000001
798R03073972187779351      05190376011000015                                   044000024265158
6220110000156534057672       0000000005ClarkGrP2C386dcTest User             S 0273970110000002
798R03073972187779351      05190376011000015                                   044000024265158
82200000020002200002000000000000000000000012A271967468                         273970110000001
9000001000001000000020002200002000000000000000000000012                                       
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

Can someone please help me to get the solution for this. ?

Regards,
Saidivya

You can't do this by editing in place.
You have to read the file one line at a time and write those lines to a new file. When you read a line starting with 6 write that line folloeed by the "79..." line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.