fo = open("output.txt", "r+") str = fo.readline() str = str[7:11] print "Read String is : ", str fo.close()