Fixed a bug in format function.

rtrim sequence was swapped