Function to generate HTML link
Simplify logic to open file