Added functionality to export to a file.