title: Cannot create a file when that file already exists error observed using Python
body: <p>I'm trying to rename files and then open it and modify data , but i am observing following error 
  [Error 183] Cannot create a file when that file already exists
   My code here :</p>
  
  <pre><code>def copy_and_replace_new_files(path, list_of_dictionary):
      ''' get to working directory'''
      os.chdir(path)
  
      ''' get each dictionary
          get all key values
          start moving files to new destination
          this will be with new name'''
      for item in iter(list_of_dictionary):
          ''' join path and source file
          copy to destination and rename'''
          src_dir = os.curdir
          dst_dir = os.path.join(os.curdir, "new")
          src_file = os.path.join(src_dir, item['filename'])
          shutil.copy(src_file, dst_dir)
  
          dst_file = os.path.join(dst_dir, item['filename'])  # old file name
          new_file_name = os.path.splitext(item['filename'])[0]
          new_file_name = new_file_name + '_new' + '.txt'
          os.rename(dst_file, new_file_name)
          ''' Find and Replace with Pattern'''
          for newline in fileinput.FileInput(new_file_name, inplace=1):
              pattern = item['table']
              pattern = str(pattern).rstrip()
              newline = newline.replace(str(pattern), str(pattern+'_new'))
              print(newline.rstrip())
  </code></pre>
  
  <p>Can you tell me where i am going wrong.</p>