One thing I can think of here that might be causing your issue is this...
When you delete a column, all subsequent columns are renumbered to reflect the now missing column no longer being there.
Two possible solutions exist:Delete from highest column number to lowest column number
Loop your process such that each time a column is deleted the 'empty check' occurs again and gives the new column number for the next empty column.
Otherwise if, for example, you had empty columns # 2, 5, 7 and full columns ranging from 1-15 (excluding those 3)... Deleting column 2 pushes everything down a number making the remaining 'empty' columns 4 and 6 instead. Deleting 4 moves it again making what was originally 7 now 5.
Conversely, if you start from highest to lowest the column renumbering doesn't affect the other 'empty' columns and no loop/recheck is required.
Hope this helps :) Please remember to mark the thread solved once your issue is resolved.