moving writing and printing functions to a separate file