libfetch: use more portable getline() interface
this is for better portability in order to avoid using a function
which is BSD-only or available via libbsd
(cherry picked from commit ee3ca711a898cf41330c320826ea1e0e6e451f1d)
(cherry picked from commit 635eb7ac7990a2bb29e1992b739617a9db012bf2)