Modified graph.print() to take an output stream as an arg