import java.io.*;
import java.util.Scanner;

public class SearchWord
{
public static void main(String[] args) throws IOException
{
Scanner sc = new Scanner(System.in);

String write;
String read;
String keyword;
int count = 0;
int countword = 0;
File input;
File output;

System.out.println("Enter the name of the file you would ");
System.out.print("like to search(include .txt): ");
read = sc.nextLine();

File searchs = new File(read);
if (!searchs.exists())
{
System.out.println(" The file you would like to search can not be found.");
System.out.print(" Please check the name and run this program again.");
System.exit(0);
}

System.out.println("Enter the name of the file you would ");
System.out.print("like to write to(include .txt): ");
write = sc.nextLine();
output = new File(write);



System.out.print("Enter the word you would like to search for: ");
keyword = sc.nextLine();


Scanner inputFile = new Scanner(searchs);

while (inputFile.hasNext())
{
String search = inputFile.nextLine();
count++;
}
inputFile.close();
System.out.println(count);
System.out.println("help");









}
}


I am new the forum and new to Java. I am a Sophmore Computer Science student. I am just looking for some points in the right direction here. This is a homework assignment and my teacher is very busy and does not have much time to assist.

My error is I need to use my search string outside my loop.

Sorry for the messy script. (its long from done)

Any help would be a blessing.
Thank you for your time,
Abs