cmd_fetch_pack(): combine the loop termination conditions