This works while (true) { key = reader.readLine(); if (key.equals("user")){ person = new Person.User(); doWork(person); } else if (key.equals("loser")){ person = new Person.Loser(); doWork(person); } else if (key.equals("coder")){ person = new Person.Coder(); doWork(person); } else if (key.equals("programmer")){ person = new Person.Programmer(); doWork(person); } else break; } } BUT THIS DOES NOT MARK CORRECTLY while (true) { if (reader.readLine().equals("user")){ person = new Person.User(); doWork(person); } else if (reader.readLine().equals("loser")){ person = new Person.Loser(); doWork(person); } else if (reader.readLine().equals("coder")){ person = new Person.Coder(); doWork(person); } else if (reader.readLine().equals("programmer")){ person = new Person.Programmer(); doWork(person); } else break; } }