writing headers (type and len still broken) before piping file