Why is the program not displaying the lines with the strings one, two, etc?
Thanks
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package file.head;
import java.io.*;
import java.util.Scanner;
/**
*
* @author Erik
*/
public class FileHead {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
String filename;
//create keyboard
Scanner keyboard = new Scanner(System.in);
//get filename
System.out.print("Please give filename: ");
filename = keyboard.nextLine();
//open file
PrintWriter outputFile = new PrintWriter(filename);
outputFile.println("one");
outputFile.println("two");
outputFile.println("three");
outputFile.println("four");
outputFile.println("five");
//close
outputFile.close();
File file = new File(filename);
Scanner inputFile = new Scanner(file);
while (inputFile.hasNext())
{
String friendName = inputFile.nextLine();
System.out.println(filename);
}
inputFile.close();
}
}