How to cut some lines from a file and paste them at certain position in a same file using python?

Solution 1:

I think you were overthinking this. It's not a hard problem.

parts = open('x.txt').read().split('\n\n')
parts.insert( 1, parts.pop(2))
print('\n\n'.join(parts))