I have run the program with various combinations and it worked as expected. Even so, it won't validate.
public class Solution {

    static String family;
    static String city;
    static String cityByUser;

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        // List of addresses
        Map<String, String> addresses = new HashMap<>();
        while (true) {
            city = reader.readLine();
            family = reader.readLine();
            if (family.isEmpty() || city.isEmpty()) break;

            addresses.put(city, family);

        // Read the city name
        cityByUser = reader.readLine();

        Iterator <Map.Entry<String,String>> iterator = addresses.entrySet().iterator();
        while (iterator.hasNext())
            Map.Entry<String, String> it1 = iterator.next();
            String family1 = it1.getValue();
            String city1 = it1.getKey();

            if (cityByUser.equals(city1)) System.out.println(family1);
            //else System.out.println("No family lives in this city");