Modified reception termination checking to handle file with size < 512