title: Python os.system cp command copies empty file
body: <p>Directory 1: I have some number of txt files and one xml file which I want to change in each iteration according to txt file content.</p>
  
  <p>Directory 2: I want to copy altered xml file to this directory after each iteration.</p>
  
  <p>After execution I can observe the altered xml file in directory 1 which contains last txt file content as expected. However, directory 2 contains empty files with expected names.
  May be there is some issue in my cp command? Could you please help?</p>
  
  <pre><code>os.system('cp /home/username/xmlFile.xml /home/username/NewFolder/%s.xml' % myString)
  </code></pre>
  
  <p>Entire script:</p>
  
  <pre><code>#!/usr/bin/python
  import os
  import re
  from shutil import copyfile
  
  arr = os.listdir('/di/rec/to/ry')
  newArr = []
  for j in arr:
          m = re.search('.*txt', j)
          if m != None:
                  newArr.append(m.group(0))
  for i in newArr:
          myString = ""
          f = open('/home/username/xmlFile.xml', 'r+')
          i = i[:-4]
          data = f.readlines()
          myString += str(i)
          data[10] = data[10][:36] + i + data[10][64:]
          f.truncate(0)
          f.seek(0)
          f.writelines(data)
          #os.system('cp /home/username/xmlFile.xml /home/username/NewFolder/%s.xml' % myString)
          copyfile('/home/username/xmlFile.xml', '/home/username/NewFolder/%s.xml' % myString)
  </code></pre>