title: Word count from a txt file program
body: <p>I am counting word of a txt file with the following code:</p>
  
  <pre><code>#!/usr/bin/python
  file=open("D:\\zzzz\\names2.txt","r+")
  wordcount={}
  for word in file.read().split():
      if word not in wordcount:
          wordcount[word] = 1
      else:
          wordcount[word] += 1
  print (word,wordcount)
  file.close();
  </code></pre>
  
  <p>this is giving me the output like this:</p>
  
  <pre><code>&gt;&gt;&gt; 
  goat {'goat': 2, 'cow': 1, 'Dog': 1, 'lion': 1, 'snake': 1, 'horse': 1, 'ï»¿': 1, 'tiger': 1, 'cat': 2, 'dog': 1}
  </code></pre>
  
  <p>but I want the output in the following manner:</p>
  
  <pre><code>word  wordcount
  goat    2
  cow     1
  dog     1.....
  </code></pre>
  
  <p>Also I am getting an extra symbol in the output (<code>ï»¿</code>). How can I remove this?</p>