Writeable

revert removing the writeable changes; also include the `perror` write function.