Added a check to see if a file exists.