why is this stuck in an infinte loop...
import java.io.*; // for IO-related functions
import java.util.*; // for the scanner class
public class FindPalindromes
{
public static void main (String[] args)
{
String inFileName;
String outFileName;
Scanner scan = new Scanner(System.in);
System.out.print("Enter the filename: ");
inFileName = scan.nextLine();
System.out.print ("Enter the output filename: ");
outFileName = scan.nextLine();
BufferedReader reader = null;
PrintWriter output = null;
try
{
reader = new BufferedReader(new FileReader(inFileName));
}
catch(FileNotFoundException e)
{
System.out.println("File " + inFileName + " not found. Exiting.");
System.exit(0);
}
try
{
output = new PrintWriter(new FileOutputStream(outFileName));
}
catch(FileNotFoundException e)
{
System.out.println("File " + inFileName + " not found. Exiting.");
System.exit(0);
}
try
{
String inputLine;
inputLine = reader.readLine();
while (inputLine != null)
{
boolean isPalindrome = true;
for( int i = 0, j = inputLine.length()-1; i < j; i++, j-- )
if( inputLine.charAt(i) != inputLine.charAt(j) )
isPalindrome = false;
if( isPalindrome )
output.println(inputLine);
}
reader.close();
output.close();
}
catch(IOException e)
{
System.out.println("Error reading from " + inFileName + ". Exiting.");
System.exit(0);
}
}
}

