added Aaron's thing to prevent errors on broken pipe. don't know if it worked...