put_text_to_buffer made safe