title: lxml library not adding newlines or indentation to tree after adding new element
body: <p>The title is self explanatory and before tagging this as duplicate please consider that I have checked <a href="https://stackoverflow.com/questions/13683014/lxml-not-adding-newlines-when-inserting-a-new-element-into-existing-xml">this answer</a> and it does not work for me because I don't even get the correct format in sys.stdout not only when writing to file. So I have the following xml (<em>test.xml</em>):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;soap:Envelope xmlns:soap="http://www..."&gt;
    &lt;soap:Body&gt;
      &lt;SubmitTransaction xmlns="http://www."&gt;
        &lt;Authentication&gt;
        &lt;/Authentication&gt;
        &lt;Transaction&gt;
          &lt;DataFields&gt;
          &lt;/DataFields&gt;
        &lt;/Transaction&gt;
      &lt;/SubmitTransaction&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>And the following code:</p>
  
  <pre><code>from lxml import etree
  
  parser = etree.XMLParser(remove_blank_text=True)
  tree = etree.parse("test.xml", parser)
  
  def get_data_fields():
      for node in tree.iter():
          if 'DataFields' in node.tag:
              return node
  a = get_data_fields()
  field = etree.Element('Field_1')
  child_1 = etree.Element('FieldName')
  child_2 = etree.Element('FieldValue')
  child_3 = etree.Element('FieldIndex')
  child_1.text = 'dateTime'
  child_2.text = '2016-07-29T12:00:00'
  child_3.text = '1'
  
  for i in [child_1, child_2, child_3]:
      field.append(i)
  a.append(field)
  
  s = etree.tostring(tree, pretty_print=True)
  print(s.decode('utf-8'))
  </code></pre>
  
  <p><strong>OUTPUT</strong></p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://www..."&gt;
    &lt;soap:Body&gt;
      &lt;SubmitTransaction xmlns="http://www."&gt;
        &lt;Authentication&gt;
        &lt;/Authentication&gt;
        &lt;Transaction&gt;
          &lt;DataFields&gt;
          &lt;Field_1&gt;&lt;FieldName&gt;dateTime&lt;/FieldName&gt;&lt;FieldValue&gt;2016-07-29T12:00:00&lt;/FieldValue&gt;&lt;FieldIndex&gt;1&lt;/FieldIndex&gt;&lt;/Field_1&gt;&lt;/DataFields&gt;
        &lt;/Transaction&gt;
      &lt;/SubmitTransaction&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p><strong>EXPECTED</strong></p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://www..."&gt;
    &lt;soap:Body&gt;
      &lt;SubmitTransaction xmlns="http://www."&gt;
        &lt;Authentication&gt;
        &lt;/Authentication&gt;
        &lt;Transaction&gt;
          &lt;DataFields&gt;
            &lt;Field_1&gt;
              &lt;FieldName&gt;dateTime&lt;/FieldName&gt;
              &lt;FieldValue&gt;2016-07-29T12:00:00&lt;/FieldValue&gt;
              &lt;FieldIndex&gt;1&lt;/FieldIndex&gt;
            &lt;/Field_1&gt;
          &lt;/DataFields&gt;
        &lt;/Transaction&gt;
      &lt;/SubmitTransaction&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>I really do not understand why new field I am adding is not formatted as supposed to, because if I print only <code>field</code>, everything looks fine:</p>
  
  <pre><code>s = etree.tostring(root, pretty_print=True)
  print(s.decode('utf-8'))
  
  #&lt;Field_1 xmlns="http://www." xmlns:soap="http://www..."&gt;
  #  &lt;FieldName&gt;dateTime&lt;/FieldName&gt;
  #  &lt;FieldValue&gt;2016-07-29T12:00:00&lt;/FieldValue&gt;
  #  &lt;FieldIndex&gt;1&lt;/FieldIndex&gt;
  #&lt;/Field_1&gt;
  </code></pre>
  
  <p>NOTE: I am using python 3.4 (this is the reason why I have to <code>.decode('utf-8')</code> otherwise I just get byte literals).</p>