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

public class FileOpener {
	public static void main(String [] args) throws Exception {
		Scanner keyboard = new Scanner(System.in);
		while (true) {
			System.out.print("filename? ");
			String filename = keyboard.next();
			if (filePrint(filename)) break;
			System.out.println("'" + filename + "' not found, try again!");
		}
	}

	static boolean filePrint(String filename) throws Exception {
		File file = new File(filename);
		if (!file.exists()) return false;
		Scanner scanner = new Scanner(file);

		while (scanner.hasNextLine()) {
			String line = scanner.nextLine();
			System.out.println(line);
		}
		return true;
	}
}
