EDIT: Problem solved! I was just blind :)
As the title says, I've been working on finding the distance between two inputted words. The dictionary file is just a file with words separated by a space. Every time that I run the program, it says that I have 0 words between the two inputted. I'm not sure what I am doing wrong.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class wordDistance {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner s = new Scanner(System.in);
        Scanner sfile = new Scanner(new File("C:/Users/name/Desktop/Eclipse/APCS/src/dictionary.txt"));
        int count = 0;
        System.out.print("Type two words: ");
        String start = s.next();
        String end = s.next();
        while (sfile.hasNextLine()) {
            String line = sfile.nextLine();
            String[] words = line.split(" ");
            for (int i = 0; i < words.length; i++) {
                if (words[i] == start) {
                    for (int j = i + 1; j < words.length; j++) {
                        if (!(words[j] == end)) {
                            count++;
                        }
                        if (words[j] == end) {
                            break;
                        }
                    }
                }
            }
        }
        System.out.println("There are " + count + " words between " + start + " and " + end);
    }
}
 
     
     
     
    