Because you are specifically saying that your data is separated solely by commas, and it isn't. The data you show has two separators: comma and newline.
Try this:
import java.util.*;
public class Main
{
public static void main (String[]args)
{
System.out.println ("Hello World");
Scanner scanner = new Scanner ("P1,19\nP2,25");
scanner.useDelimiter (",|\\n");
while (scanner.hasNextLine ())
{
String s = scanner.next ();
scanner.skip (scanner.delimiter ());
int num = scanner.nextInt ();
System.out.println (s);
System.out.println (num);
}
}
}