Main change:
It is not clear the fragile ls -l $2 | awk '{print $5}' was chosen as a way to get file size, so have replaced with stat -f%z "$2"
Other minor changes:
Use $(...) notation instead of legacy backticks
Double quote to prevent globbing and word splitting