bad interpreter: Text file busy

You appear to be having this issue, which is because at some point nvi started opening files O_RDWR instead of O_RDONLY.

If your vi is in fact nvi, I'd try using a different vi, say vim.