Same command is giving different output on terminal and .sh script

I have a small .sh script, as below (ignore /dev/null , that's a hack I am using;

#!/bin/bash

while read host port; do

echo `timeout 5 telnet $host $port </dev/null 2>&1 > /dev/null` >> sample_output.txt

done < ip_port.txt

The file ip_port.txt has following content;

host_ip1 port1
host_ip2 port2

when I am running the command on terminal, I am getting correct output on sample_output.txt as "Connection Closed by foreign host"

echo `timeout 5 telnet $host $port </dev/null 2>&1 > /dev/null` >> sample_output.txt

but when I executing .sh, the file sample_output.txt is blank.