I got the output as: >>> Yes!!! This line will always print from the code: try: fsock = open("c:/TEMP/hello.txt") except IOError: print "The file does not exist, exiting gracefully" print "Yes!!! This line will always print" it means the code found there is hello.txt, why it does not show on the output.