Thanks for the hint! I've gone through the code and changed "print" statements to sys.stderr.write.