Endless loop bug (size not updated before check)