The previous code had bug when reading lines with an unexpected
encoding, returning without the full line being captured.
This result in sort complaining with "sort: Illegal byte sequence"
Using getline(3) instead of the home made code, fixes the situation.
PR: 241679