import random

f = open('in.txt')
line = []
while True:
    sw = f.readline()  # читаем из файла in.txt строки
    if len(sw) == 0:
        break
    line.append(sw)
line[-1] += '\n'
f.close()
random.seed(version=2)
random.shuffle(line)  # миксуем список
f = open('out.txt', 'w')
for i in range(5):
    f.write(line[i])  # выводим в файл out.txt
f.close()