From the comments we know that you're getting the following error:
curl: (3) Illegal characters found in URL
If formatted this way:
while IFS="$IFS"$'\r' read line; do
curl "https://x.com/v1/PhoneNumbers/$line?Type=carrier" -u "x:x"
done < "${1:-/dev/stdin}"
your command should work.
The problem is that your appending \r at the end of your input lines (so that every line of your input ends with a \r\n sequence). By default read does not strip trailing r. If we want read to trim those characters we have to add this character to the IFS environmental variable for read like this: IFS="$IFS"$'\r')" read ....
Here's a great comment from Charles Duffy:
Personally, I'd suggest IFS=$' \t\n\r', not referring to the old $IFS value -- why make your code's behavior contextually dependent?
Another valuable comment; this time from chepner:
Granted, a valid line probably isn't going to contain a \r, but conceptually, you don't want to treat a carriage return as whitespace; you just want to strip the \r that is part of the \r\n line ending. Instead of modifying IFS, read the line normally, then strip it with line=${line%$'\r'} before calling curl.
Related: