title: Creating a program which counts words number in a row of a text file (Python)
body: <p>I am trying to create a program which takes an input file, counts the number of words in each row and writes a string of that certain number in another output file. I managed to develope this code:</p>
  
  <pre><code>in_file = "our_input.txt"
  out_file = "output.txt"
  f=open(in_file)
  g=open(out_file,"w")
  for line in f:
      if line == "\n":
          g.write("0\n")
      else:
          g.write(str(line.count(" ")+1)+"\n")
  </code></pre>
  
  <p>now, this works well, but the problem is that it works for only a certain amount of lines. If my input file has 8000 lines, it will display only the first 6800. If it has 6000, than will be displayed (all numbers are rounded, right).
  I tried creating another program, which splits each line to a list, and then counting the length of it, but the problem remains just the same.
  Any idea what could cause this?</p>