Converted printer to take a writer as an argument