Bash script puts \r at the end of variable

I'm pretty new to bash scripts and I'm trying to work through some issues. Would appreciate any suggestions.

I have a list of servers in a text file (I used the FQDN's), I assign the file name to a variable, I then use cat to read the list of file names and echo them to the screen. But when it assigns the variable it seems to append a \r to the end of the variables value. Although the \r doesn't show up unless I use the set command to debug. As you can see from code below, I'm trying to use a server list to perform a secure copy of my password files so that I don't have to log on to each server. Here is the code snippet in question:

#!/bin/bash
#
set -x

FILENAME=server_list.txt

cat $FILENAME | while read LINE
do
        echo "$LINE"
#       mkdir /sysadmin/bin/passwd_audit/$LINE
#       scp root@$LINE:/etc/passwd /sysadmin/passwd/$LINE-passwd.txt
#       scp root@$LINE:/etc/group /sysadmin/passwd/$LINE-group.txt
#       scp root@$LINE:/etc/sudoers /sysadmin/passwd/$LINE-sudoers.txt

done

set +x

Here are the first few lines in the file:

Here's what the output from the script looks like:

Is this normal behavior? I've used this same script in the past and it's worked fine for me. Not sure why it changed suddenly. Any suggestions would be greatly appreciated.

Your data file was probably edited on windows, a \r on the end of each line is standard in MSDOS.

You can use

$ dos2unix server_list.txt

to remove these \r chars.

Chubler, you rock. That did the trick, thank you so much.