if (flags|O_TRUNC) is the worst code in the history of code. Changed to
& to only truncate the file when actually asked for.