I have five lines of text in a text file that I want to read and write in the following way:
- read 1st line and copy it to new text file 1.
- read 1st and 2nd line and copy them to new text file 2.
- read 1st, 2nd and 3rd line and copy them to new text file 3.
- read 1st, 2nd, 3rd and 4th line and copy them to new text file 4.
- read all lines and copy them to new text file 5.
I have tried something with loops, but I just get confused. Or maybe to use recursion....?
I created a basic solution for you.. Please check for the rest, this is just for help you out.