import java.util.Scanner;
import java.io.File;
import java.io.PrintWriter;
import java.io.FileNotFoundException;


class Nov3v2 {
	public static void main(String[] args) {

		Scanner kb = new Scanner(System.in);
		PrintWriter pw = null;

		try {
			File f = new File("family-names.txt");
			pw = new PrintWriter(f);
		}
		catch (FileNotFoundException e) {
			System.out.println("File not found");
			return;
		}

		String input = null;
		boolean start = true;
		do {
			System.out.print("Enter name: ");
			input = kb.next();
			if(!input.equals("exit")) {
				if(!start) {
					pw.print(",");
				}
				pw.printf(input+".txt");
			}
			start = false;
		}while(!input.equals("exit"));
		pw.println();
		pw.close();

		// read names from file and print to the screen

		Scanner fin = null;
		
		try {
			File f = new File("family-names.txt");
			fin = new Scanner(f);
		}
		catch (FileNotFoundException e) {
			System.out.println("File not found");
			return;
		}
		
		fin.useDelimiter("(.txt|,|\n)+");
		while(fin.hasNext()) {
			String name = fin.next();
			System.out.println(name);
		}
	
		int[][] matrix = new int[5][5];

		for(int i = 0; i < matrix.length; i++) {
			for(int j = 0; j < matrix[i].length; j++) {
				matrix[i][j] = (int) (Math.random() * 10 + 1); 
			}
		}

		for(int[] row : matrix) {
			for(int x : row) {
				System.out.printf("%d ", x);
			}
			System.out.println();
		}	

	}
}
