fixed bug in writelabel code causing it to fail when writing a 0 byte