title: how do i make open two file with same name under 1 variable for difference function?
body: <p>i make 2 loop that has to open 2 same file name req.txt. i want to input only 1 file but read by the two loop. i had done below but not valid.. error msg </p>
  
  <blockquote>
    <p>line 32, in 
        with open(requestfile,'r') as rqfile: TypeError: coercing to Unicode: need string or buffer, file found</p>
  </blockquote>
  
  <pre><code>onefile= './req.txt'
  with open(onefile, 'r') as requestfile:
  #rqfile = rrr = requestfile
  
      with open(requestfile,'r') as rqfile:
          for line in rqfile:           
              line = line.rstrip()        
              if line.startswith('Referer: '): 
                  urll = line[9:]      
              elif line.startswith('Cookie: '):
                  cookie=line[18:]
              elif line.startswith('Host: '):
                  host=line[6:]
  
      rqfile.close()
  
  with open(requestfile,'r') as rrr:
      for i, line in enumerate(rrr):  
  
          if i == 14:
  
              username = line[:line.index('=')]
              password = line[line.index('&amp;') + 1:line.index('=', line.index('=') + 1)]
                  print(username, password)
  rrr.close()
  </code></pre>