Refactored updating the gen_file

Moved the logic for updating the gen_file into a function of its own.
Merge pull request #1 from natec425/master

Refactored updating the gen_file