Error handling, and code reduction

Most significant is catching NULL char* result when magic_file is passes a path to a non-existent file (and I suspect other cases that return NULL).