Extracted method to write URI to buffer
Methods to write the name and URI are extracted.