title: When scanning input from a file to a struct, and then saving the changes, why does it always write to the first line and erases everything else?
body: <p>So for my school project im making a program which makes a user profile with some basic information. This information is saved in the following struct, however when i try and change one of the parameters in the saved profile, say the age. I load the profile into the struct, ask the user what they want to change, then change it. Then close up by running the profile saver which saved all the information (which has now been changed)</p>
  
  <p>The problem im having trouble with is, that when i change something within the struct and then try to save the changes it saves the change how it is supposed to, however it erases everything else in the file, which in turn ruins the loader, as the strings are no longer present i presume</p>
  
  <pre><code>struct profile_info
  {
  char first_name[30];
  char last_name[30];
  char gender;
  int age;
  int height;
  double weight;
  }user_profile;
  </code></pre>
  
  <p>profile saver</p>
  
  <pre><code>/* this function til take the data inputted from the user and save to a .txt
  file on the local pc */
  void profile_saver(struct profile_info user_profile)
  {
  FILE *file_pointer;
  
  file_pointer = fopen("test.txt", "w+");
  
  fprintf(file_pointer, "%s\n%s\n %c\n%d\n%d\n%lf", user_profile.first_name, user_profile.last_name,
  user_profile.gender, user_profile.age, user_profile.height, user_profile.weight);
  
  fclose(file_pointer);
  }
  </code></pre>
  
  <p>and the profile loader</p>
  
  <pre><code>/* this function will load the user profile if such a profile exists */
  void user_profile_loader(struct profile_info user_profile)
  {
  FILE *file_pointer;
  file_pointer = fopen("test.txt", "r");
  
  fscanf(file_pointer, "%s", user_profile.first_name);
  
  fscanf(file_pointer, "%s", user_profile.last_name);
  
  fscanf(file_pointer, " %c", &amp;(user_profile.gender));
  
  fscanf(file_pointer, "%d", &amp;(user_profile.age));
  
  fscanf(file_pointer, "%d", &amp;(user_profile.height));
  
  fscanf(file_pointer, "%lf", &amp;(user_profile.weight));
  
  printf("Following profile has been loaded \n%s \n%s \n%c \n%d \n%d \n%lf\n", user_profile.first_name, user_profile.last_name,
  user_profile.gender, user_profile.age, user_profile.height,     user_profile.weight);
  
  fclose(file_pointer);
  }
  </code></pre>
  
  <p>Finally, the changer, explained in the start</p>
  
  <pre><code>void profile_changer(struct profile_info user_profile)
  {
  int user_change_choice;
  
  user_profile_loader(user_profile);
  
  printf("What would you like to change? \nFirst name &gt; 1 \nLast name &gt; 2 \nGender &gt; 3 \nAge &gt; 4 \nHeight &gt; 5 \nWeight &gt; 6");
  scanf("%d", &amp;user_change_choice);
  
  switch(user_change_choice)
      {
      case 1:
      printf("Please enter your new first name ");
      scanf("%s", user_profile.first_name);
      break;
      case 2:
      printf("Please enter your new last name ");
      scanf("%s", user_profile.last_name);
      break;
      case 3:
      printf("Please enter your new gender ");
      scanf(" %c", &amp;(user_profile.gender));
      break;
      case 4:
      printf("Please enter your new age ");
      scanf("%d", &amp;(user_profile.age));
      break;
      case 5:
      printf("Please enter your new heigt ");
      scanf("%d", &amp;(user_profile.height));
      break;
      case 6:
      printf("Please enter your new weight ");
      scanf("%lf", &amp;(user_profile.weight));
      }
  
  profile_saver(user_profile);
  
  }
  </code></pre>