In an action brought upon a bond for the payment of money, wherein the plaintiff shall recover, judgment shall be entered for the penalty of the bond, to be discharged by the payment of the principal and interest due and costs of suit, and execution shall issue accordingly. However, if before judgment the defendant shall bring into court the principal and interest due upon the bond, he shall be discharged, and in that case judgment shall be entered for the costs alone.