How to create a new file with my ArrayBuffer as the content?

I want to create a new file which contains my ArrayBuffer (binary) as content.

var file = new Blob([response], {type: "application/octet-binary;charset=utf-8"});
		var a = document.createElement("a"), url = URL.createObjectURL(file);
        a.href = url; = filename;

I have tried the above code but the console complains the the length is invalid. I believe when i copy the content of the file and save it into my project as .txt file the length changes so my other functions fail to run.

is there a way to save it properly without running into this issue?