Fix FILE handle leak, push FILE handle work down into __statlog_log_one().

While we're at it, close the log FILE handle when we're done, and check
all log FILE handle close calls for errors.