Assuming that making . active and defining its meaning to be print a period and execute \formatcommand solves your problem (and you have not anything that could sneak in a \write such as a label containing a period), let's see a couple of alternatives.