explicitly made all fprintf unsinged ints type cast to unsigned long to aid portability between 32bit and 64bit architectures