Fix issue where it was writing every entry in 1 file. Fix issue in creating files without leading zeros.