I have a file with this format:
611 2856 618 2582 94075 94107 94065 94068
101071 94104
598 2856 618 611 93995 94107 93992 93991
94075 94065
612 2834 2821 2812 94087 101577 94085 94081
101558 101557
I need to read the lines and to rewrite them so:
611 2856 618 2582 94075 94107 94065 94068 101071 94104
598 2856 618 611 93995 94107 93992 93991 94075 94065
612 2834 2821 2812 94087 101577 94085 94081 101558 101557
I have tried something like this:
f2 = open('new_file.txt', 'w')
f1 = open('old_file.txt')
lines = f1.readlines()
for i, line in enumerate(lines):
print(repr(line))
f2.write(line)
i = i+1
f1.close()
f2.close()
But it is not working as it writes again every line. I need to read two lines and write them in one. Any suggesitons?