STS-3478: added extra guard to prevent closed or deleted file from being accessed