Except $6 won't always be the file size, nor will $5 always be the port number or $4 the IP. Those are only true if filename has no spaces in it.
See the fix in the other thread