Bug with closing file is fixed