stop loop after 2nd times word in arraylist : Hello guys i wrote program to add a name to array list but if you wrote 2nd times the same word the loop stop and write You gave the word twice. but i dont know where is problem. can you help me somebody?

package recurring.word;

import java.util.ArrayList;
import java.util.Scanner;

public class RecurringWord {

    public static void main(String[] args) {
        
        ArrayList<String> words = new ArrayList<String>();
       
       Scanner reader = new Scanner(System.in);
       
       while(true){
           System.out.print("Type a word: ");
            String name = reader.nextLine();
            
            words.add(name);
        
            if (words.contains(name)) {
                break;
                                        
                  }
                     
              System.out.println("You gave the word " + name + "twice");
        }
       
          
    } 
    
}