Fixed printing to file