fixed: CRITICAL:__main__:Serious Error occured: local variable 'fh' referenced before assignment