diff --git a/files/add_latest_thinlinc_client_to_repos b/files/add_latest_thinlinc_client_to_repos
index 021232932f779249c72599a9a483dfce79783b46..214a91086217f94761d15c9a454db425bdab32aa 100755
--- a/files/add_latest_thinlinc_client_to_repos
+++ b/files/add_latest_thinlinc_client_to_repos
@@ -6,13 +6,15 @@ cleanup() {
 }
 trap cleanup 0
 
+set -o pipefail
+
 ensure_client_downloaded() {
     local url="$1" filename="$2"
     [ -f "$filename" ] && return
     curl --silent --show-error -o "${WORKDIR}/${filename}" "$url"
 }
 
-if ! latest_client_url="https://www.cendio.com$(curl --silent --show-error https://www.cendio.com/thinlinc/download | grep -Eo '/downloads/clients/thinlinc-client-[^"]+.x86_64.rpm')"; then
+if ! latest_client_url="https://www.cendio.com$(curl -L --silent --show-error https://www.cendio.com/thinlinc/download/ | grep -Eo '/downloads/clients/thinlinc-client-[^"]+.x86_64.rpm')" | head -1; then
     exit 1
 fi