added try catch block when reading files