In addition to the above answers you can also use .once in a similar way to .output. This outputs only the next query to the specified file, so that you don't have to follow with .output stdout.
So in the above example
.mode csv
.headers on
.once test.csv
select * from tbl1;