If any write fails, 'r > 0' will become false and the while loop will terminate, preventing any further writes.