title: python3 TypeError: invalid file: <_io.TextIOWrapper name='~/file1' mode='r' encoding='UTF-8'>
body: <pre><code>parser = argparse.ArgumentParser()
  
  parser.add_argument('-TNm', '--file1', type=argparse.FileType('r'), required=True)
  
  parser.add_argument('-Css', '--file2', type=argparse.FileType('w'), required=True)
  
  parser.add_argument('-Iacs', '--file3',type=argparse.FileType('w'), required=True)
  
  args = parser.parse_args()
  
  def main(args):
  
          with open(args.file1) as TN, open(args.file2) as Cs, open(args.file3) as Ia:
  
              for line in enumerate(TN):
                  ....................   #processing each line and its indice
  
  
  if __name__ == '__main__':
  
         main(args) 
  </code></pre>
  
  <p>I run this script by  </p>
  
  <pre><code>python3 ~/script.py -TNm ~/file1 -Css ~/file2 -Iacs ~/file3
  </code></pre>
  
  <p>And an error was given:</p>
  
  <pre><code>TypeError: invalid file: &lt;_io.TextIOWrapper name='~/file1' mode='r' encoding='UTF-8'&gt;
  </code></pre>
  
  <p>Is there something wrong with <code>enumerate(TN)</code>? </p>