Fix detection of failure on zeroth index in buffer

When the failure is detected on the zeroth index of the buffer the detection failed due to the non-false test. This is corrected.

In addition, I changed the deprecated gets to fgets and eliminated some compiler errors to clean things up a bit.