The write method was wrong as well as there were missing pieces in the class for it to work properly.