If you use with you do not need to close the file anymore please adjust also in the other places you do this.