Revert "Remove usage of deprecated write_attribute"

This reverts commit df1472418b23bf4ce31198b332f573b0a70275a6.