The shelf label is short, but it still has to fit in label. Format it into the array and check the return value before showing it.
snprintf(label, sizeof label, ...) to create Shelf #3; check error/truncation before printing it.A return value equal to the capacity means truncation. Do not print the label in that case, even if the buffer contains a terminated partial string.
Check written < 0 or (size_t)written >= sizeof label before puts.