In [4]:
from collections import Counter
#import re

word_dict = Counter()
#  with will automaticlly close your file
with open('text.txt', 'r') as file:
    for line in file:
        print "line is: \n", line
        print "line.split() is: \n", line.split()
        word_dict.update(line.split())
word_dict


line is: 
You are watching a film in which two men are having a fight. They hit one another hard. At the start they only fight with their fists. But soon they begin hitting one another over the heads with chairs. And so it goes on until one of the men crashes through a window and falls thirty feet to the ground below. He is dead!Of course he isn't really dead. With any luck he isn't even hurt. Why? Because the men who fall out of high windows or jump from fast moving trains, who crash cars of even catch fire, are professionals. They do this for a living. These men are called stuntmen. That is to say, they perform tricks.There are two sides to their work. They actually do most of the things you see on the screen. For example, they fall from a high building. However, they do not fall on to hard ground but on to empty cardboard boxes covered with a mattress . Again, when they hit one another with chairs, the chairs are made of soft wood and when they crash through windows, the glass is made of sugar!But although their work depends on trick of this sort, it also requires a high degree of skill and training. Often a stuntman' s success depends on careful timing. For example, when he is "blown up" in a battle scene, he has to jump out of the way of the explosion just at the right moment.

line.split() is: 
['You', 'are', 'watching', 'a', 'film', 'in', 'which', 'two', 'men', 'are', 'having', 'a', 'fight.', 'They', 'hit', 'one', 'another', 'hard.', 'At', 'the', 'start', 'they', 'only', 'fight', 'with', 'their', 'fists.', 'But', 'soon', 'they', 'begin', 'hitting', 'one', 'another', 'over', 'the', 'heads', 'with', 'chairs.', 'And', 'so', 'it', 'goes', 'on', 'until', 'one', 'of', 'the', 'men', 'crashes', 'through', 'a', 'window', 'and', 'falls', 'thirty', 'feet', 'to', 'the', 'ground', 'below.', 'He', 'is', 'dead\xef\xbc\x81Of', 'course', 'he', "isn't", 'really', 'dead.', 'With', 'any', 'luck', 'he', "isn't", 'even', 'hurt.', 'Why?', 'Because', 'the', 'men', 'who', 'fall', 'out', 'of', 'high', 'windows', 'or', 'jump', 'from', 'fast', 'moving', 'trains,', 'who', 'crash', 'cars', 'of', 'even', 'catch', 'fire,', 'are', 'professionals.', 'They', 'do', 'this', 'for', 'a', 'living.', 'These', 'men', 'are', 'called', 'stuntmen.', 'That', 'is', 'to', 'say,', 'they', 'perform', 'tricks.There', 'are', 'two', 'sides', 'to', 'their', 'work.', 'They', 'actually', 'do', 'most', 'of', 'the', 'things', 'you', 'see', 'on', 'the', 'screen.', 'For', 'example,', 'they', 'fall', 'from', 'a', 'high', 'building.', 'However,', 'they', 'do', 'not', 'fall', 'on', 'to', 'hard', 'ground', 'but', 'on', 'to', 'empty', 'cardboard', 'boxes', 'covered', 'with', 'a', 'mattress', '.', 'Again,', 'when', 'they', 'hit', 'one', 'another', 'with', 'chairs,', 'the', 'chairs', 'are', 'made', 'of', 'soft', 'wood', 'and', 'when', 'they', 'crash', 'through', 'windows,', 'the', 'glass', 'is', 'made', 'of', 'sugar!But', 'although', 'their', 'work', 'depends', 'on', 'trick', 'of', 'this', 'sort,', 'it', 'also', 'requires', 'a', 'high', 'degree', 'of', 'skill', 'and', 'training.', 'Often', 'a', "stuntman'", 's', 'success', 'depends', 'on', 'careful', 'timing.', 'For', 'example,', 'when', 'he', 'is', '"blown', 'up"', 'in', 'a', 'battle', 'scene,', 'he', 'has', 'to', 'jump', 'out', 'of', 'the', 'way', 'of', 'the', 'explosion', 'just', 'at', 'the', 'right', 'moment.']
line is: 


line.split() is: 
[]
line is: 
Naturally stuntmen are well paid for their work, but they lead dangerous lives. They often get seriously injured, and sometimes killed. A Norwegian stuntman, for example, skied over the edge of a cliff a thousand feet high. His parachute failed to open, and he was killed. In spite of all the risks, this is no longer a profession for men only. Men no longer dress up as women when actresses have to perform some dangerous action. For nowadays there are stuntgirls tool.

line.split() is: 
['Naturally', 'stuntmen', 'are', 'well', 'paid', 'for', 'their', 'work,', 'but', 'they', 'lead', 'dangerous', 'lives.', 'They', 'often', 'get', 'seriously', 'injured,', 'and', 'sometimes', 'killed.', 'A', 'Norwegian', 'stuntman,', 'for', 'example,', 'skied', 'over', 'the', 'edge', 'of', 'a', 'cliff', 'a', 'thousand', 'feet', 'high.', 'His', 'parachute', 'failed', 'to', 'open,', 'and', 'he', 'was', 'killed.', 'In', 'spite', 'of', 'all', 'the', 'risks,', 'this', 'is', 'no', 'longer', 'a', 'profession', 'for', 'men', 'only.', 'Men', 'no', 'longer', 'dress', 'up', 'as', 'women', 'when', 'actresses', 'have', 'to', 'perform', 'some', 'dangerous', 'action.', 'For', 'nowadays', 'there', 'are', 'stuntgirls', 'tool.']
line is: 
In some ways, the United States has made some progress. Fires no longer destroy 18,000 buildings as they did in the Great Chicago Fire of 1871, or kill half a town of 2,400 people, as they did the same night in Peshtigo, Wisconsin. Other than the Beverly Hill Supper Club fire in Kentucky in 1977, it has been four decades since more than 100 Americans died in a fire.

line.split() is: 
['In', 'some', 'ways,', 'the', 'United', 'States', 'has', 'made', 'some', 'progress.', 'Fires', 'no', 'longer', 'destroy', '18,000', 'buildings', 'as', 'they', 'did', 'in', 'the', 'Great', 'Chicago', 'Fire', 'of', '1871,', 'or', 'kill', 'half', 'a', 'town', 'of', '2,400', 'people,', 'as', 'they', 'did', 'the', 'same', 'night', 'in', 'Peshtigo,', 'Wisconsin.', 'Other', 'than', 'the', 'Beverly', 'Hill', 'Supper', 'Club', 'fire', 'in', 'Kentucky', 'in', '1977,', 'it', 'has', 'been', 'four', 'decades', 'since', 'more', 'than', '100', 'Americans', 'died', 'in', 'a', 'fire.']
line is: 


line.split() is: 
[]
line is: 
But even with such successes, the United States still has one of the worst fire death rates in the world. Safety experts say the problem is neither money nor technology, but the indifference of a country that just will not take fires seriously enough.

line.split() is: 
['But', 'even', 'with', 'such', 'successes,', 'the', 'United', 'States', 'still', 'has', 'one', 'of', 'the', 'worst', 'fire', 'death', 'rates', 'in', 'the', 'world.', 'Safety', 'experts', 'say', 'the', 'problem', 'is', 'neither', 'money', 'nor', 'technology,', 'but', 'the', 'indifference', 'of', 'a', 'country', 'that', 'just', 'will', 'not', 'take', 'fires', 'seriously', 'enough.']
Out[4]:
Counter({'"blown': 1,
         '.': 1,
         '100': 1,
         '18,000': 1,
         '1871,': 1,
         '1977,': 1,
         '2,400': 1,
         'A': 1,
         'Again,': 1,
         'Americans': 1,
         'And': 1,
         'At': 1,
         'Because': 1,
         'Beverly': 1,
         'But': 2,
         'Chicago': 1,
         'Club': 1,
         'Fire': 1,
         'Fires': 1,
         'For': 3,
         'Great': 1,
         'He': 1,
         'Hill': 1,
         'His': 1,
         'However,': 1,
         'In': 2,
         'Kentucky': 1,
         'Men': 1,
         'Naturally': 1,
         'Norwegian': 1,
         'Often': 1,
         'Other': 1,
         'Peshtigo,': 1,
         'Safety': 1,
         'States': 2,
         'Supper': 1,
         'That': 1,
         'These': 1,
         'They': 4,
         'United': 2,
         'Why?': 1,
         'Wisconsin.': 1,
         'With': 1,
         'You': 1,
         'a': 15,
         'action.': 1,
         'actresses': 1,
         'actually': 1,
         'all': 1,
         'also': 1,
         'although': 1,
         'and': 5,
         'another': 3,
         'any': 1,
         'are': 8,
         'as': 3,
         'at': 1,
         'battle': 1,
         'been': 1,
         'begin': 1,
         'below.': 1,
         'boxes': 1,
         'building.': 1,
         'buildings': 1,
         'but': 3,
         'called': 1,
         'cardboard': 1,
         'careful': 1,
         'cars': 1,
         'catch': 1,
         'chairs': 1,
         'chairs,': 1,
         'chairs.': 1,
         'cliff': 1,
         'country': 1,
         'course': 1,
         'covered': 1,
         'crash': 2,
         'crashes': 1,
         'dangerous': 2,
         'dead.': 1,
         'dead\xef\xbc\x81Of': 1,
         'death': 1,
         'decades': 1,
         'degree': 1,
         'depends': 2,
         'destroy': 1,
         'did': 2,
         'died': 1,
         'do': 3,
         'dress': 1,
         'edge': 1,
         'empty': 1,
         'enough.': 1,
         'even': 3,
         'example,': 3,
         'experts': 1,
         'explosion': 1,
         'failed': 1,
         'fall': 3,
         'falls': 1,
         'fast': 1,
         'feet': 2,
         'fight': 1,
         'fight.': 1,
         'film': 1,
         'fire': 2,
         'fire,': 1,
         'fire.': 1,
         'fires': 1,
         'fists.': 1,
         'for': 4,
         'four': 1,
         'from': 2,
         'get': 1,
         'glass': 1,
         'goes': 1,
         'ground': 2,
         'half': 1,
         'hard': 1,
         'hard.': 1,
         'has': 4,
         'have': 1,
         'having': 1,
         'he': 5,
         'heads': 1,
         'high': 3,
         'high.': 1,
         'hit': 2,
         'hitting': 1,
         'hurt.': 1,
         'in': 8,
         'indifference': 1,
         'injured,': 1,
         'is': 6,
         "isn't": 2,
         'it': 3,
         'jump': 2,
         'just': 2,
         'kill': 1,
         'killed.': 2,
         'lead': 1,
         'lives.': 1,
         'living.': 1,
         'longer': 3,
         'luck': 1,
         'made': 3,
         'mattress': 1,
         'men': 5,
         'moment.': 1,
         'money': 1,
         'more': 1,
         'most': 1,
         'moving': 1,
         'neither': 1,
         'night': 1,
         'no': 3,
         'nor': 1,
         'not': 2,
         'nowadays': 1,
         'of': 16,
         'often': 1,
         'on': 6,
         'one': 5,
         'only': 1,
         'only.': 1,
         'open,': 1,
         'or': 2,
         'out': 2,
         'over': 2,
         'paid': 1,
         'parachute': 1,
         'people,': 1,
         'perform': 2,
         'problem': 1,
         'profession': 1,
         'professionals.': 1,
         'progress.': 1,
         'rates': 1,
         'really': 1,
         'requires': 1,
         'right': 1,
         'risks,': 1,
         's': 1,
         'same': 1,
         'say': 1,
         'say,': 1,
         'scene,': 1,
         'screen.': 1,
         'see': 1,
         'seriously': 2,
         'sides': 1,
         'since': 1,
         'skied': 1,
         'skill': 1,
         'so': 1,
         'soft': 1,
         'some': 3,
         'sometimes': 1,
         'soon': 1,
         'sort,': 1,
         'spite': 1,
         'start': 1,
         'still': 1,
         'stuntgirls': 1,
         "stuntman'": 1,
         'stuntman,': 1,
         'stuntmen': 1,
         'stuntmen.': 1,
         'success': 1,
         'successes,': 1,
         'such': 1,
         'sugar!But': 1,
         'take': 1,
         'technology,': 1,
         'than': 2,
         'that': 1,
         'the': 23,
         'their': 4,
         'there': 1,
         'they': 10,
         'things': 1,
         'thirty': 1,
         'this': 3,
         'thousand': 1,
         'through': 2,
         'timing.': 1,
         'to': 8,
         'tool.': 1,
         'town': 1,
         'training.': 1,
         'trains,': 1,
         'trick': 1,
         'tricks.There': 1,
         'two': 2,
         'until': 1,
         'up': 1,
         'up"': 1,
         'was': 1,
         'watching': 1,
         'way': 1,
         'ways,': 1,
         'well': 1,
         'when': 4,
         'which': 1,
         'who': 2,
         'will': 1,
         'window': 1,
         'windows': 1,
         'windows,': 1,
         'with': 5,
         'women': 1,
         'wood': 1,
         'work': 1,
         'work,': 1,
         'work.': 1,
         'world.': 1,
         'worst': 1,
         'you': 1})

In [ ]: