import java.io.*;

public class ContactInput
{
	// Create a single shared BufferedReader for keyboard input
	private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) );
		
	public static void main (String [] args) throws IOException
	{
		System.out.print( "Enter the filename: " );   // Prompt the user for a file name
		String fileName = stdin.readLine();           // get a file name from the user
		
		Contact [] myContacts;
		int numContacts = 0;
		
		File file = new File( fileName ); // create a File object
		
		if ( file.exists() )	// check that the file exists
    	{						// before trying to create a
								// BufferedReader

			// Create a BufferedReader from the file
			BufferedReader inFile = new BufferedReader( new FileReader( file ) );
			
			// Compare the results of calling the readLine method to null
			// to determine if you are at the end of the file.
			String line = inFile.readLine();
			while ( line != null )
			{
				line = inFile.readLine();	// read another line from the file
				numContacts++;
			}
			
			numContacts = numContacts / 3; // for every three lines of input, there is one contact
			
			// Close the buffered reader input stream attached to the file
			inFile.close();
			
			inFile = new BufferedReader( new FileReader( file ) );	//reopen the file for reading
			myContacts = new Contact[numContacts];
			
			for (int i = 0; i < numContacts; i++)
			{
				String firstname = inFile.readLine();
				String lastname = inFile.readLine();
				String phone = inFile.readLine();
				
				myContacts[i] = new Contact(firstname, lastname, phone);
			}
			
			for (int i = 0; i < numContacts; i++)
				System.out.println(myContacts[i]);
		}
	}
}