The problem root is that you are picking a random number too close to the end of the list.
After you pick the random number, you deplete the list three times at that location.
So the limit for picking a random index should be length(list)-2, to allow for removing length(list)-2, ...-1, ...-0.
Also, you replenish the list when it is empty, but that is not enough.
If your list has length < 3, it won't have enough items to satisfy your triple depletion.
So change that IF test at the top from IF LIST IS EMPTY to IF LENGTH(LIST) < 3
ABG