char* buffer = malloc(sizeof(line));
It is quite probable that we are not reserving enough memory, better to do:
char* buffer = malloc(strlen(line) + 1);
the use of strtok is incorrect, the pointers returned by strtok are as follows:
We only need ...