OK firstly you are reading the line data into
line
which is on the stack and you are returning a pointer to it. When the function goes out-of-scope the stack is reclaimed. Instead, you will need to strdup()
it and the caller will need to free()
it.