fix bug in writing file where same stimulus was calculated