Swap write functions.

Replace the old write functions with the new write functions.

See #364.