Minor Bug Fix in write_cobra_model_to_sbml_file to Allow Default Compartments to be created

hasattr will return true if the attribute exists, even if the field is empty. This caused problems for me because a compartment list didn't get generated, which was needed by another tool I was using.

My first commit fixes the actual problem. The second commit just makes the code more readable by putting the relevant lines together. I tested the code after both changes.