Added old write() function