"Index out of range" while reading contents from a file through cat PYTHON : <p>I am trying to get input from a file, through cat command, into a python file. My python version is 3.5. The code looks like this. </p>

<pre><code>with open(sys.argv[1]) as f:
    while True:
        if f.readline()== '':
            break
        line = f.readline().strip()
</code></pre>

<p>And i am getting the input through the following command. </p>

<pre><code>python cptest.py | cat ts.csv
</code></pre>

<p>But i keep running into the following error.</p>

<blockquote>
  <p>File "cptest.py", line 9, in 
      with open(sys.argv[1]) as f:
  IndexError: list index out of range</p>
</blockquote>

<p>How can i send input to a python script from a file using cat command? I have to use cat command, or any other way i can pipe the input to the file.</p>
