Amended to_file() method.