check for nil writer before trying to publish to it