Non fai prima a fare:

codice:
Scanner sc = new Scanner (System.in);

for (.....)
{
    String line = sc.nextLine ();
    ....
}
?