Define const + check fclose + fwrite errors