How you are seeing the output of fprintf is not correct. It may be that you file viewer is doing some tricks.