How to add vocabulary terms to a taxonomy category
taxonomy_vocabulary_machine_name_load() returns an object or FALSE. You're checking for exactly TRUE by using ===.

Any of the following should work (sorted by my preference):

if ($vocabulary) {
if (is_object($vocabulary)) {
if ($vocabulary !== FALSE) {
if ($vocabulary == TRUE) { // only two equal signs here