Added ERROR print to write fails