write keys in bucket into file keys.bin