Added a 'writeElement' method.