Update adjust-midstate.py

fixed wrong closing of the file