If doing this based on a query that has been interactively developed, the easiest way is:
.mode csv .output myfile.csv SELECT * FROM mytable; -- or whatever query you want .output -- to reset output to console