Added new to_file() method.