This should be moved to the end of the method so that the flag is set only if the file was successfully opened.