fixed ckpt file writing