Fixed bug in append mode which would overwrite instead of appending