Added check if the file is not closed