I have this script for years, I use it to scramble words in a text file. But I have a file line by line, and the script is shuffling but it deletes the line break he's leaving everything on the same line, do you have any solution for this? I tried 'sort -r' but it just does the reverse, it doesn't shuffle.
import random
file = open('myfile.txt', 'r')
text = file.read()
file.close()
text = text.split()
random.shuffle(text)
text = ' '.join(text)
print(text)