I think the problem was
'why does it say "file not found"'
and not
'how can I stop the error if the file is not found'
Your code is 100% correct and should be used whenever you are not sure that a file exists, but in this case the question was more "why was the file not found?"