title: sys.argv[1], IndexError: list index out of range
body: <p>I am having an issue with the following section of Python code:</p>
  <pre><code># Open/Create the output file
  with open(sys.argv[1] + '/Concatenated.csv', 'w+') as outfile:
  
      try:
          with open(sys.argv[1] + '/MatrixHeader.csv') as headerfile:
              for line in headerfile:
                  outfile.write(line + '\n')
      except:
          print 'No Header File'
  </code></pre>
  <p>Specifically the error is as follows:</p>
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File &quot;ConcatenateFiles.py&quot;, line 12, in &lt;module&gt;
      with open(sys.argv[1] + 'Concatenated.csv', 'w+') as outfile:
  IndexError: list index out of range
  </code></pre>
  <p>I've done some research and it seems that the <code>sys.argv</code> might require an argument at the command line when running the script, but I'm not sure what to add or what the issue might be! I've also searched the site, but all of the solutions I've found either have no comments and/or don't include the open function as mine does.</p>