I'm not sure if you're running total is referring to the summed saving or to the amount to deposit. Given the result of deposit, I'd suspect that's to be deposit. You'd need to move the sum before the loop and initialize it to save, then add deposit to it within the loop. Simple as that.
header('HTTP/1.1 420 Enhance Your Calm');