diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id
index 4bba5d6..ed1208e 100644
--- a/contrib/ssh-copy-id
+++ b/contrib/ssh-copy-id
@@ -207,7 +207,7 @@ populate_new_ids() {
printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2
NEW_IDS=$(
eval $GET_ID | {
- while read ID ; do
+ while read ID || [[ -n $ID ]]; do
printf '%s\n' "$ID" > $L_TMP_ID_FILE
# the next line assumes $PRIV_ID_FILE only set if using a single id file - this