I am using Python 3 and want to turn something into a while loop : I am using Python 3 and want to turn something into a while loop but I am new so I am having some trouble with this.

PS - sorry if the code below has wrong indentations, as I am still getting used to stack overflow, they are correct in my program

        username_chosen = input("Enter the username of the user for their details :")
        with open("data.txt") as f:
            for line in f:
                if username_chosen in line:
                    print(line)

The loop I want is where the program keeps checking if there is a username as the one entered by the user and if there is not then it tells them error and prompts them to input again until the program can find the username. 

        