I have a function which reads stop words from a file and saves it in a HashSet.

```
HashSet<String> hset = readFile();

```

This is my string 

```
String words = "the plan crash is invisible";

```

I am trying to remove all the stop words from the string but it is not working correctly

**The output i am getting:** plan crash invible

**Output i want =>** plan crash invisible

Code:

```
HashSet<String> hset = readFile();
        String words = "the plan crash is invisible";

        String s = words.toLowerCase();

        String[] split = s.split(" ");
        for(String str: split){
            if (hset.contains(str)) {

                s = s.replace(str, "");

            } else {

            }

        }

        System.out.println("\n" + "\n" + s);

```