Looks like your file may not be getting closed due to a typo in the way the close function is called .
text_EnteredCode.close
should be
text_EnteredCode.close()
This should solve the issue that you are facing.