Fix to_file method for Pull #19