working code for length text buffer.