write metadata too, strip newlines