diff --git a/file.c b/file.c
index 4213f5e31a0cbb00abfb9bf143b26c7c1a374e8a..f0761b15ef5a1be0e7120c7191b6f7de0ef55932 100755
--- a/file.c
+++ b/file.c
@@ -855,8 +855,12 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
 		return NULL;
 	}
 	/* set the O_TRUNC flag if and only if there is no O_APPEND specified */
-	if (!(flags & O_APPEND)) 
+	if (flags & O_APPEND) { 
+		/* We really can't use O_APPEND as it will break WAV header updates */
+		flags &= ~O_APPEND;
+	} else {
 		myflags = O_TRUNC;
+	}
 	
 	myflags |= O_WRONLY | O_CREAT;