title: How to make data entered by user to appear below headers
body: <p>This is my code for entering student details. Once the user has entered the details and inputs yes, the details are exported to StudentDetails.csv (Microsoft Excel) where it should go below the headers but ends up going somewhere else.</p>
  
  <pre><code>def EnterStudent():
      uchoice_loop = False
      ask_loop = False
      while uchoice_loop == False:
              surname = raw_input("What is the surname?")
              forename = raw_input("What is the forname?")
              date = raw_input("What is the date of birth? {Put it in the format D/M/Y}")
              home_address = raw_input("What is the home address?")
              home_phone = raw_input("What is the home phone?")
              gender = raw_input("What is their gender?")
              tutor_group = raw_input("What is their tutor group?")
              email = (forename.lower() + surname.lower() + ("@school.com"))
              print(surname+" "+forename+" "+date+" "+home_address+" "+home_phone+" "+gender+" "+tutor_group+" "+email)
              ask = raw_input("Are these details correct?"+"\n"+"Press b to go back, or yes to add entered data on your student.").lower()
              if ask == "yes":
                      f = open("StudentDetails.csv","rt")
                      lines = f.readlines()
                      f.close()
                      lines.append(surname+","+forename+","+date+","+home_address+","+home_phone+","+gender+","+tutor_group+","+email+"\n")
                      f = open("StudentDetails.csv", "w")
                      f.writelines(lines)
                      f.close()
                      uchoice_loop = True
                      printMenu()
              elif ask == "b":
                      uchoice_loop = False
              else:
                   print("Plesase enter 'b' to go back or 'yes' to continue")
  </code></pre>
  
  <p>This is my csv file.
  <a href="https://i.stack.imgur.com/sxSya.png" rel="nofollow noreferrer">enter image description here</a></p>