use sizeof to determine buffer size for fgets

Fixes GHI#64.