loop to receive entire file