Im trying to write a program that reads a txt file and copy's all the lines in an array of strings and then sorts the strings by the length and then outputs the array of sorted strings...It compiles error free, but it just fails to run.It just freezes...It 100% something I messed up with pointers....

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void sortLines(char *line[]);
void printLines(char *line[]);

int main(int argc,char **argv){

	char *lines[200]; //200 pointers on lines
	char buffer[100]; // max length of the line
	int i=0;

	FILE *fp;

	if((fp=fopen("file.txt","r"))==NULL)
	{
		printf("File openinng error!\n");
		exit(1);
	}

	 while((i<200)&&(1==fscanf(fp,"%s",buffer)))
	 {
		 lines[i]=malloc(strlen(buffer)+1); /*we allocate space for lines*/
		 strcpy(lines[i],buffer); /*copy the buffer into that space*/
		 i++;
	 }

   sortLines(lines);
   printLines(lines);

     fclose(fp);
	 return 0;

}

void sortLines(char *line[])
{
     int j=0;
	 char *temp;
	 int i;
	 while((j<200) && (line[j]!=NULL)) /*if there is less than 200 lines allocated, we have to checkl if the pointer is NULL too*/
	 {
		  for(i=0;i<200;i++)
		  {
			  if((strlen(line[i])) < (strlen(line[j])))
			  {
				  temp=line[i];
				  line[i]=line[j];
				  line[j]=temp;
			  }
		  }
		  
		  j++;
	 }
}

void printLines(char *line[]){
	int j=0;
	while((j<200)&&(line[j]!=NULL))
	{
      
         printf("%s\n",line[j]);
		 free(line[j]);  /*after we print out the line we free the pointer*/
		 j++;
	}
}