in reply to File pieces

If you're using *nix, don't reinvent the wheel. Take a look at the split utility.