def write_tag(tag)
      # Group 0002 is always little endian, but the rest of the file may be little or big endian.
      # When we shift from group 0002 to another group we need to update our endian/explicitness variables:
      switch_syntax_on_write if tag.group != META_GROUP and @switched == false
      # Write to binary string:
      bin_tag = @stream.encode_tag(tag)
      add_encoded(bin_tag)
    end
def write_tag(tag)
      # Group 0002 is always little endian, but the rest of the file may be little or big endian.
      # When we shift from group 0002 to another group we need to update our endian/explicitness variables:
      switch_syntax_on_write if tag.group != META_GROUP and @switched == false
      # Write to binary string:
      bin_tag = @stream.encode_tag(tag)
      add_encoded(bin_tag)
    end
Encodes and writes a tag (the first part of the data element).

 @param [String] tag a data element tag