Welcome to the Streamlit community, and thanks for sharing your question and code! The issue is that your get_text_download_link function always sets st.session_state.textpara to the most recent link_text —which, after your loop, is always the last hyperlink (“5Teshing”). Clicking a hyperlink in Markdown/HTML does not trigger a Streamlit rerun or update session state; it just downloads the file.