Check for NAN before fprintf, consistent error formatting.