need to combine two text files of girl names and boy names into one text file. the new file has to have the boy names and girl names separated into two lists of each gender, and we dont know how many names each file will have. the program runs but gets stuck in an infinite loop
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Scanner;
public class NameTester
{
public static void main(String args[]) throws FileNotFoundException
{
Scanner userIn = new Scanner(System.in);
System.out.println("Enter file name for boys name file: ");
String boyFile = userIn.next();
System.out.println("Enter file name for girls name file: ");
String girlFile = userIn.next();
userIn.close();
Scanner boyIn = new Scanner(new FileReader(boyFile));
Scanner girlIn = new Scanner(new FileReader(girlFile));
PrintWriter out = new PrintWriter("names.txt");
out.print("Boys Names: Girls Names: ");
int count = 1;
while(boyIn.hasNextLine() || girlIn.hasNextLine());
{
String b = boyIn.next();
String g = girlIn.next();
out.print(count + " " + b + " " + count + " " + g);
count++;
}
boyIn.close();
girlIn.close();
out.close();
}
}