For loop not executing properly

Hello guys, I seem to have a slight problem with a pesky for loop that wont work properly, here is the code of the for loop :
if(GUI.Button (new Rect(2,15+(11buttonHeight)+2,50,buttonHeight),“A”)){
for(int i = 0; i < loot.Count; i++){
Inventory.Add(loot
);*
_ loot.Remove (loot*);_
_
}_
_
}_
The purpose of this is to Loot everything in the list of loot and add it to the Inventory list, however, when i hit the button, only 1/2 of the loot gets transferred per click. Here is the entire code that governs this : ( forgive me but its in a pretty bad shape atm )
_
///

_
_
/// InventoryManager.cs*_
/// Jc Cloete
///
/// This Script is responsible for managing the inventory of each individual player
///

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class InventoryManager : MonoBehaviour {
* public List Inventory;*
* public List loot;*
* public int colGained;*

* public int buttonHeight;*
* public int buttonStartingPos;*

* public Vector2 inventoryScrollPosition;*
* public Rect inventoryScrollViewRect;*
* public Rect inventoryScrollUseRect;*
* public int inventoryButtonWidth;*
* public Rect lootWindowRect = new Rect (500,20,250,300);*
* public bool showLootWindow = true;*

* void Start () {*
* loot = new List ();*
* buttonStartingPos = 30;*
* buttonHeight = 25;*
* Loot ();*
* Inventory = new List ();*
* for (int i =0; i < 15; i++) {*
* Inventory.Add(new Item());*
* }*
* for (int i = 0; i < 10; i++) {*
* loot.Add (new Item()); *
* }*
* SortInventory ();*
* }*

* void Update () {*
_ inventoryScrollUseRect = new Rect (30, 30, 110, Inventory.Count * buttonHeight + 5);_
* }*

* void OnGUI(){*
* inventoryScrollPosition = GUI.BeginScrollView (inventoryScrollViewRect, inventoryScrollPosition, inventoryScrollUseRect);*
* for(int cnt = 0; cnt < Inventory.Count; cnt++){*
_ if(GUI.Button(new Rect(30,buttonStartingPos + (cnt * buttonHeight) +2,100,25),Inventory[cnt].Name)){
* Debug.Log (Inventory[cnt].Name+ " button press");*
* }*
* }*
* GUI.EndScrollView ();*
* if (showLootWindow) {*
* lootWindowRect = GUI.Window(0,lootWindowRect,LootWindow,“Loot:”); *
* }*
* }*
* public void SortInventory(){*
* Inventory.Sort (delegate(Item x, Item y) {*
* return x.Name.CompareTo (y.Name);*
* });*
* }*
* public void AddItem(Item item){*
* Inventory.Add (item);*
* }*
* public void RemoveItem(Item item){*
* Inventory.Remove (item);*
* }*
* public void Loot(){*
* colGained = Random.Range (1, 5000);*
* }*
* void LootWindow(int ID){*
* for (int i = 0; i < loot.Count; i++) {*
if(GUI.Button (new Rect(2,15 + (i * buttonHeight) +2,inventoryButtonWidth,buttonHeight),loot*.Name)){
Debug.Log ("looted : " + loot.Name);
}
}
GUI.Label (new Rect (2, 15 + (10 * buttonHeight) + 2, inventoryButtonWidth, buttonHeight), "Col Gained : " + colGained);
if(GUI.Button (new Rect(2,15+(11buttonHeight)+2,50,buttonHeight),“A”)){

* for(int i = 0; i < loot.Count; i++){
Inventory.Add(loot);
loot.Remove (loot);
}
}
if (CheckLootEmpty ()) {
showLootWindow = false;
}
else {
showLootWindow = true;
}
GUI.DragWindow ();
}
public bool CheckLootEmpty(){
if (loot.Count == 0) {
return true;
}
else {
return false;
}
}
}*

I have a list of buttons on a window that represents each item, so when i click the loot all button, they all should go away, however , only 1/2 of them goes away, the rest stays untill i have clicked multiple times, If anyone can help me out with this I would be forever gratefull, ( Again, sorry that the code is in such a state, i just HATE coding GUI in the current version of unity)
PS>>> give me some tips on this code lol, I’m not really good with unity’s current gui solution_

I think once you remove something at position 1, the thing that was at position 2 gets moved to position 1, so you’d probably avoid this issue by looping in reverse:

for(int i=loot.Count-1; i>=0; i--)
{
        Inventory.Add(loot*);*

loot.Remove (loot*);*
}