finish to fill the file. TODO: generate checksum