When you call player.removeweapon() then its modifying player.weapons[], that's why the loop is only removing 14. Possible solution would be
PHP Code:
for (i=player.weapons.size()-1; i>=0; i--)
player.removeweapon(player.weapons[i].name);
(might be confusing but player.weapons is a special intelligent object which lets you print the player weapon list as string even when there are weapons which don't really exist, and by using weapons[] you can still directly access the weapon npc)