title: Going to a specific position in a file
body: <p>I am fairly new to python. I have been doing a project that i have been struggling on recently and I'd be glad if i can receive some help. </p>
  
  <p>I am conducting a programme in which will take an input from a user and see if the input is seen in the file. The input is a name tag, e.g. the user will have to type in a unique code like 't56700' and then the programme will see if the code is in the file. However, along with the code comes with other information. </p>
  
  <p>What i need to do is to take in a user input, and if it's valid, i would need to jump to where that input is located on the file and print the code (the name tag) along with all the information with it.</p>
  
  <p>The file looks like this:</p>
  
  <p>nametag,x,x,x</p>
  
  <p>nametag,x,x,x</p>
  
  <p>nametag,x,x,x</p>
  
  <p>^ Several lines of this</p>
  
  <p>This is my code so far, I'm trying to get to where the user's input is seen on the file and print the info along with it. </p>
  
  <pre><code>file = open("filetest.txt","r").readlines()
  
  
  nametag = input ("What is your name tag?")
  
  if nametag in open('filetest.txt').read():
  
      with open('filetest.txt', 'r') as searchfile:
  
          for line in searchfile:
                      if nametag in line:
  
  
  
                          print ("nametag: " + nametag)
                          print ("xxxx ", line[2])
                          print("xxxx:",line[3])
                          print("xxxx:",line[1])
                          print("xxxx:",line[4])
  
                          break 
  </code></pre>
  
  <p>The numbers within the square brackets like 'line[2]' for example only take me to the start of the file and not the location at where i want the file to read from.</p>