Thank you Ancient One!
The lack of a space after the comma delimeter was precisely the problem. Without it, the return for 40 was "3,2,1," before truncating and "3,2," after, so it was deleting the final comma and the character preceding it. Putting the space in fixed it. It would have taken...