REFACTORED. Added io.Writer functions.