gen: fix close file when writing new config

Signed-off-by: Alberto Corona <alberto@0x1a.us>