Include sys/types.h for cpputil functions
Check result of ofstream operation the right way
Fix compile errors when checking for empty C-style strings