fixed close of file issue