Remove use of unportable fgetln and replace it by getline from libc