Add a check to make sure that 100% of the file is sent before closing connection