editor: wait for data in a loop

The first packet of data might not be sufficient for our needs,
so make sure we wait until enough data has arrived. If an error
occurs, break out and let the reading code-do the clean-up.