Fix a bug in gen_script.py