Set needsScan to false at the end of a scan instead of at the beginning in order to keep scanning when an exception occurs during a scan (SLING-6786).