Fix generate.file method