p. 120 - in the second code snippet there seems to be one missing statement:
write_customer
between the following two lines:
@balance = @balance.add(transaction_amount, 2) # |
# --> here, I think, write_customer call is missing
file.close # <--