Your code looks fine to me, except for one thing.
Short answer: add "break;" after "Temp18B20.reset_search();"
Long answer:
There is a problem with the OneWire library. But that's for an infinite loop, which you aren't running into.
Here's the fix for it anyway:
Could you post a running output? Something like:
while(j < 6){
Serial.print(j);
Serial.print(", ");
if ( !Temp18B20.search(addr)) {
Temp18B20.reset_search();
Serial.print("reset ");
}
Serial.print(addr[1], HEX);
}
This will help us get an idea of the pattern that the search function returns.
I think you'll find you get something like:
0, 0x7C
1, 0x21
2, reset 0x21
3, 0x7C
4, 0x21
5, reset 0x21
This is because the third "unneccesary" loop is necessary in order to hit the "Temp18B20.reset_search();" line.
In the example code, there is a "return;" after this line, but in your case you don't want to break out of the function, just the loop. Thus, replace "return;" with "break;"
A better way would be to loop twice (like you expected) and then add a "Temp18B20.reset_search();" at the end of your function (after all the calculations are done). This should also work, as long as your sensors are all functioning properly and you don't add any more sensors. Then you could have the fail safe conditional "if ( !Temp18B20.search(addr)) {" end with "return false;" so that if you get there (which you shouldn't if you're reading twice, and have two good sensors) you know something is wrong, and the function shuts down the pump.
Glad the project is working! Keep it up!