It seems there is no to_file param in your def line. Did you forget it? :)