I'm trying to use scanner to print lines from a text file, but it only prints first line before printing only new lines until while loop goes through file.

```
String line;
File input = new File("text.txt");
Scanner scan = new Scanner(input);
while (scan.hasNext()) //also does not work with hasNextLine(), but additional error
{
line = scan.nextLine();
System.out.println(line);
//other code can see what is in the string line, but output from System.out.println(line); is just a new line
}

```

How can I get System.out.println() to work with this code?