If loop exit is caused by $i being greater than or equal to $cnt, do try to append...