title: How to solve PermissionError: [Errno 13] Permission denied
body: <p>Hello so I am getting this error permission denied when I run this python script.</p>
  <pre><code>import os
  
  keyword = input(&quot;Enter Keyword to search : &quot;)
  replacement = input(&quot;Enter replacement string : &quot;)
  
  for filename in os.listdir():
     with open(os.path.join(os.getcwd(), filename), 'r') as f: # open in readonly mode
         content = f.read()
         if keyword in content:
             with open(os.path.join(os.getcwd(), filename), 'w') as fw: # open in write mode
                 writecontent = content.replace(keyword, replacement)
                 fw.write(writecontent)
                 print(f&quot;Keyword {keyword} found and replaced in file : {filename}&quot;)
  
  
  input(&quot;Press Enter to exit&quot;)
  </code></pre>
  <p>the error I am getting is</p>
  <pre><code>Traceback (most recent call last):
    File &quot;c:/Users/smraf/Desktop/Test Python/script.py&quot;, line 9, in &lt;module&gt;
      with open(os.path.join(os.getcwd(), filename), 'r') as f:
  PermissionError: [Errno 13] Permission denied: 'C:\\Users\\username\\Desktop\\Test Python\\.vscode'
  </code></pre>
  <p>The problem is when I run this on a different laptop it works. My coworker tried running it on theirs and it doesn't work either so I am not sure why it's giving me this error.</p>