From looking at your VI I would guess its a communication problem. Does "string output" show any data after running the VI? As the channel name (IC) seems to be the only difference and you don't seem to define it at the beginning where you define channel IB are you sure you are defining it correctly later on?
You write to the file until no string remains. "Error 5" output contains an error condition: "; HP 4145 Receive Message", so most likely, nothing was received in frame 4 and nothing will be written.
Something needs a longer timeout. Your code should also check for error condition so it can take correctove actions, e.g. repeat frame 4 after a short wait until something is received and the error no longer occurs.