Only close file when opened [1222636]
No need to close file as it cannot be opened when error [1222635]