I'm trying to write a scanner so that every time \n is detected, it will scan the line after that until a new \n shows up. I first tried something like this.

```
import java.util.Scanner;

public class test{

    public static void main(String[] args) {

        String input = "first line \nsecond line \nthird line";

        Scanner sc = new Scanner(input);

        while(sc.hasNextLine()) {
            String stuff = sc.nextLine();
            System.out.println(stuff);
        }
        sc.close();
    }
}

```

Which works, and the output is

```
first line 
second line 
third line

```

However, when I try doing the same thing with Scanner(System.in) it doesn't work the same way even with same input

```
import java.util.Scanner;

public class test{

    public static void main(String[] args) {
        System.out.println("Please enter things");

        Scanner cmd = new Scanner(System.in); //input: "first \n second \n third"

        String input = cmd.nextLine();

        Scanner sc = new Scanner(input);

        while(sc.hasNextLine()) {
            String stuff = sc.nextLine();
            System.out.println(stuff);
        }
        cmd.close();
        sc.close();
    }
}

```

Output:

```
first \n second \n third

```

What should I change, so that every \n will print a new line?
=============================================================

EDIT:
If the input was

```
first
second
third

```

and entered into the prompt at once, would scanner.nextLine() be enough to suffice?