BSD compat
use fgets
Merge pull request #1 from mjhoy/bsd-compat

BSD compat