Added option to write headers or not