index-pack: refactor writing of .keep files