Forse volevi scrivere questo?

codice:
public class Esercizio1 {
    public static void main (String [] args) throws IOException {

        System.out.println("Frase: ");
        Scanner sc = new Scanner(System.in);
        String[]S;
        do {
            String s=sc.nextLine();
            S = s.split(",");

            for (String q:S)
                System.out.println(q);
        } while (sc.hasNextLine());

        sc.close();
    }
}