Do better checks on fwrite and how about we use the output of mkdir in our debug info