England survived a late collapse to beat New Zealand by one wicket and keep their World Cup hopes alive.