Modified print_and_log to use file paths rather than file objects. Much cleaner.