Added a function to check files existence.