Changed write method. Included spaces to be sent