I have text file containing numbers with different number of newlines. How can I remove the new lines except the ones.
Example of numbers I have in text file
1
2
3
4
2
If I do open('thefile.txt').read().replace('\n', '')
I will get everything in one line. How can I get output like this.
1
2
3
4
2