title: IOError: [Errno 2] No such file or directory trying to open a file
body: <p>I am very new to Python so please forgive the following basic code and problem, but I have been trying to figure out what is causing the error I am getting (I have even looked at similar threads on S.O.) but can't get past my issue.</p>
  
  <p>Here is what I am trying to do:</p>
  
  <ul>
  <li>loop through a folder of CSV files</li>
  <li>search for a 'keyword' and delete all lines containing the 'keyword'</li>
  <li>save output to a separate folder</li>
  </ul>
  
  <p>Here is my code:</p>
  
  <pre><code>import os, fnmatch
  import shutil
  
  src_dir = "C:/temp/CSV"
  target_dir = "C:/temp/output2"
  keyword = "KEYWORD"
  
  for f in os.listdir(src_dir):
      os.path.join(src_dir, f)
      with open(f):
          for line in f:
              if keyword not in line:
                  write(line)
                  shutil.copy2(os.path.join(src_dir, f), target_dir)
  </code></pre>
  
  <p>Here is the error I am getting:</p>
  
  <pre class="lang-none prettyprint-override"><code>IOError: [Errno 2] No such file or directory: 'POS_03217_20120309_153244.csv'
  </code></pre>
  
  <p>I have confirmed that the folder and file do exist. What is causing the <code>IOError</code> and how to I resolve it? Also, is there anything else wrong with my code that would prevent me from performing the entire task?</p>