while (%current <= %total_amount){

replace with

while (%current <= %total_amount) {