import java.io.FileWriter;
import java.io.BufferedReader;
import java.util.Random;
import java.util.ArrayList;
import java.io.FileReader;
import javax.swing.JOptionPane;
import java.io.IOException;
import java.util.Scanner;

public class LinearSearch
{

ArrayList words;
FileReader reader;
BufferedReader in;

public LinearSearch() throws IOException
{ words = new ArrayList();
String word;
reader = new FileReader("C:/New folder (2)/longListOfWords.txt");
in = new BufferedReader(reader);
int count = 0;
boolean done = false;
while (! done)
{     word = in.readLine();
    if (word == null) done = true;
    else
        words.add(word);
}
}

public void search()
{ Scanner in = new Scanner(System.in);
System.out.println("Which word are you looking for?");
String sought = in.next();
String wordFromList;
boolean done = false;
int i = 0;
while ( ! done && i < words.size() )
{     wordFromList = words.get(i);
    System.out.println(wordFromList);
    if (wordFromList.equals(sought))
    {     System.out.println(sought + " is in the list.");
        done = true;
    }
i++;
}
if ( ! done)
    System.out.println(sought + " is not in the list.");
}

public static void main(String[] args) throws IOException
{ LinearSearch ls = new LinearSearch();
ls.search();
}
}