Network Backup Configuration - telnetlib (Python)

i Have the below script in python, the goal is create a python script using telnetlib and backup a cisco router configuration to an external file. However, everytime i run this script it hangs. any help or recommendations would be much appreciated.

import telnetlib
import getpass
import time
import os


ip_add=raw_input('Please enter IP your would like to back up: ')
os.chdir('/Users/user/Backup_configuration/')

uname = raw_input('Please enter username for {} :'.format(ip_add))
print 'Please enter Password for {} :'.format(ip_add)
passwd = getpass.getpass()


connect = telnetlib.Telnet(ip_add)

connect.read_until('Username: ')
connect.write(uname+'\n')

connect.read_until('Password: ')
connect.write(passwd + '\n')

connect.write('config t\n hostname changed1\n end \n terminal len 0\n wr mem\n' )
time.sleep(3)

connect.write('show run\n')
out = connect.read_all()


filen= open('telnet_file.txt', 'w')
filen.write(out)
filen.close()