Computercraft automatic enchantment sorter

local chest = peripheral.wrap("front")
print("Radcom's Enchantment sorter V1.2")
while true do
    sleep(1)
    for i = 1, chest.getInventorySize() do
        local item = chest.getStackInSlot(i)
        if item and item.ench then
            print("Found a ", item.name, " with an enchantment")
            print("Moving")
            chest.pushItem("south",i,1)
        else
            if item then
                print("moving: ",item.qty, " ",item.name)
                chest.pushItem("east",i,item.qty)
            end
        end
     end
end