Fix a problem with remote-sync inefficiency by adding a flag to indicate 'end-of-input'