Created a ifelse statemennt where one condition leads to file opening and one condition after checking if file exist or not leads to the download of file.