Add logging for try-catch blocks and if the file is not valid, proper check for validity of a file