Fix infinite loop bug in fmt