public void run() { connection.start(); System.out.println("\n\nChat started"); System.out.print("you: "); Scanner scanner = new Scanner(System.in); while (true) { if (scanner.hasNextLine()) { System.out.println("yo"); String line = scanner.nextLine(); connection.sendMessage(line); System.out.println(); if (line.contains("endsession")) { break; } } } System.out.println("Session ended."); connection.endSession(); scanner.close(); }