title: Adding header to .txt file - doesn't iterate through list of files
body: <p>My script aims to add headers to some text files that are currently defined in a list.
  After that, it should combine the text files into one.</p>
  
  <p>However I'm stuck with this error code here. I wouldn't want to do the same for-loop for every file needed:</p>
  
  <pre><code>    Traceback (most recent call last):
    File "/infa/app/ZRH_PCE_DEV/PCE_DATA_ANALYTICS/Scripts/mergerPCE_nodes.py", line 90, in &lt;module&gt;
      for line in fileinput.input([stock_files], inplace=True):
    File "/infa/mgmt/au/.pyenv/versions/3.8.2/lib/python3.8/fileinput.py", line 248, in __next__
      line = self._readline()
    File "/infa/mgmt/au/.pyenv/versions/3.8.2/lib/python3.8/fileinput.py", line 336, in _readline
      os.fspath(self._filename) + (self._backup or ".bak"))
  TypeError: expected str, bytes or os.PathLike object, not list
  </code></pre>
  
  <p>Is it somehow possible to still iterate through the list?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#Locations
  merge_directory_name = 'MergedFiles'
  input_path = file_home
                #'/infa/app/ZRH_PCE_DEV/PCE_DATA_ANALYTICS/SrcFiles/PCELogs/'
  output_path = merged_path
                #'/infa/app/ZRH_PCE_DEV/PCE_DATA_ANALYTICS/SrcFiles/PCELogs/MergedFiles'
  #output_name = 'pc_dblatmonstat_merged_' + str(datetime.now().strftime('%Y-%m-%d-%H-%M') + '.csv')
  output_name = 'nodes_merged.txt'
  
  stock_files = sorted(glob(raw_path + '/*.sccloud.xxx.com_node.log'))
  print(bcolors.OKBLUE + 'Getting .log files from', raw_path)
  print(*stock_files, sep='\n')
  
  
  headers = ["Timestamp",
             "Log"
    ]
  
  for line in fileinput.input([stock_files], inplace=True):
      if fileinput.isfirstline():
          print( '\t'.join(headers))
      print(line)
  
  
  #read in files via list comprehension
  content = [pd.read_csv(f, sep='[;]',engine='python') 
             for f in stock_files]
  print(bcolors.OKBLUE + 'Reading files')
  
  #combine files into one dataframe
  combo = pd.concat(content,ignore_index = True)
  print(bcolors.OKBLUE + 'Combining files')
  
  
  
  #drop duplicates
  combo = combo.drop_duplicates
  print(bcolors.OKBLUE + 'Dropping duplicates')
  
  #Create new directory for merged file
  #file_home is '/infa/app/ZRH_PCE_DEV/PCE_DATA_ANALYTICS/SrcFiles/PCELogs/'
  merge_directory = Path(file_home, merge_directory_name).mkdir(parents=True, exist_ok=True)
  print(bcolors.OKBLUE + "Directory '% s' created" % merge_directory_name)
  
  
  #write to txt:
  combo.to_txt(output_path + output_name, index = False)
  print(bcolors.OKGREEN + 'Merged file output to', output_path, 'as', output_name)
  print(bcolors.RESET + '')
  </code></pre>