writing and printing a file