from random import randint def randomline(filename): with open(filename, "r") as file: print("Reading from file " + filename) lines = file.readlines() seed = len(lines) - 1 rando = randint(0, seed) theline = (lines[rando])[:-1] return theline if __name__ == "__main__": filename = str(input("Filename:\n")) want = True while want: print("\n→ " + randomline(filename) + "\n") promp = str(input("Another? [Y/n]\n")) if promp == "n": want = False print("\n… Exiting")