Changed the script for Mac OS X compatibility (should still work on other platforms, too).