I have the following in a text file:

line1
text1
text2
text3
line2
something1
something2

I want to create another text file that looks like this:

line1|text1|text2|text3
line2|something1|something2

Whenever a line in the text file says "line" I want to add each line below it to that line with a '|' delimiter. Can I do this in Python?

Edit
Report