how do i read data fom a file from each line and i store it into a structure array : 	#include<stdio.h>
	#include<stdlib.h>
	#include<string.h>
	#include "struct.h"
	struct student{
	char command[10];
	char value[50];
	char user[50];

	};

				int main(){
					int size,i;
					struct student s1[256];
					FILE *file = fopen("file.txt","r");

					if (file == NULL){

						printf("Error in reading student data");
						return 1;

						}
					size = 0;

					while(fscanf(file,"%s,%s,%s",s1[size].command,s1[size].value,s1[size].user)!=EOF) {
						printf("%s%s%s\n",s1[size].command,s1[size].value,s1[size].user);
				                  printf("%s\n",s1[size].command);
						size++;
					}



	             fclose(file);

	return 0;
	}


Above is my, i have been working on this part for some structure am create a c socket server that can process data for clients.
but i got a problem in file handling. I wanted to pick data from a file and store it into a structure at specific portions and then i erase the file according to data i have picked.
i.e

a,w,a
r,e,1
I wanted to pick data from my file which contains the above information  and i store it in specific portions of my structure array
ie if store a in 

          s1[0].command, w in s1[0].value......

          r in  s1[1].command, e in s1[1].value......etc
But when i try running my code it prints 

       a,w,a in s1[0].command  and r,e,1 in s1[1].command.
so am kindly requesting for help because i have tried googling but i couldn't get a solution. 