you should have that file i/o in some try: except: pairs for starters. and you should close data_file when you are done. isn't it just data_file.read() ?