I think your problem is that
int selection = scanner.nextInt();
reads just the number, not the end of line or anything after the number. When you declare
String sentence = scanner.nextLine();
This reads the remainder of the line with the number on it (with nothing after the number I suspect)
Try placing a scanner.nextLine(); after each nextInt() if you intend to ignore the rest of the line.