Changed writing from print to .write