title: Python: Reading input from a file?
body: <p>I have a text file of the format: </p>
  
  <pre><code>2
  1 3
  2 4
  </code></pre>
  
  <p>I have written a python program that asks for number of inputs and prints out the values sum .</p>
  
  <pre><code>n = int(raw_input())
  for _ in range(n):
       a,b = map(int,raw_input().split())
       print a+b
  </code></pre>
  
  <p>But</p>
  
  <ol>
  <li>How should I take input from file such that first line is number of test cases and next lines are inputs?</li>
  <li>Print the output to a file?</li>
  </ol>