It is very difficult to guess from this code snippet what is exactly happening.
Can it be there is still data receiving when you set VaTerminal.Comm = nil?
You'd typically set this to nil before you send the command that the file data can be sent, so no data is received at the same time as you set VaTerminal.Comm = nil