The default standard input handling of ssh drains the remaining line from the while loop.
To avoid this problem, alter where the problematic command reads standard input from. If no standard input need be passed to the command, read standard input from the special /dev/null
device:
while read LINE
do
R_USER=$(echo $LINE | cut -d ',' -f 1)
R_HOST=$(echo $LINE | cut -d ',' -f 2)
PY_SCRIPT=$(echo $LINE | cut -d ',' -f 4)
ssh $R_USER@$R_HOST 'touch /home/user/file_name.txt' < /dev/null
done
Or alternatively, try using ssh -n
which will prevent ssh from reading from standard input. For instance:
ssh -n $R_USER@$R_HOST 'touch /home/user/file_name.txt'