/*
	The program demonstrate a simple File Exception
	
* 
*/
import java.util.*; // Needed for Scanner class
import java.io.*;	// Needed for File input and output

public class FileException
{
	public static void main(String[] args)
	{
		Scanner key = new Scanner(System.in);
		
		try
		{
			// Opens the file or create a file if it doesn't exist
		
			PrintWriter pw = new PrintWriter("Name.txt");
			
			for(int i=0; i<3; i++)
			{
				// Gets the name from the user
				
				System.out.println("Enter a name: ");
				String name = key.nextLine();
				
				// Writes the name into the file
				pw.println(name);
			}
			
			/*
				Closes the file
				A step that always need to remember to do
			
			*
			*/
		
			pw.close();
		}
		catch(IOException ae)
		{
			System.out.println("Invalid");
			System.exit(0);
		}

	}
}