You read entire file to find the number of lines..so at the end file pointer has reached the end.. What do you think happens when you call 'fscanf' again ??
You need to reset your file pointer to start again
printf("%d lines\n",lines);
rewind(in);
int i = 0;