ok, i done your code and you was just overcomplicateing it so i refined it:
while true do
for dropitems=1,16 do
turtle.attack()
turtle.select(dropitems)
turtle.drop()
end
end
i tested it and this works fine:) also, you can name dropitems to what ever you want if you want to...