for n, line in enumerate(data):
    if line.startswith('line'):
        data[n] = '\n' + line.rstrip()
else:
    data[n] = line.rstrip()
How can I combine multiple lines of text into one line in Python with a delimiter to separate them?