fgetln: provide a version not relying on getline()

`getline()` is not POSIX and is a GNU extension.