updated filetype and added header writing