It usually happens when you PC cant save the replay completely.
This could happen due to the lag, or as it was already said, due to editing.
There isnt really a way to fix it, unless you edit the replay file with notepad.
Though, you need to know what you are doing.