Why do we need rnd.shuffle(lines_index) twice, first outside of the while True loop and then inside the loop? Could we just live with the second one only that is inside the loop? I wonder what the role of the first one is.
Shuffles the first time entering the loop, then reshuffles every time you run the loop for randomness!