Setting permissions without setting owner and group can have rather inconvenient results. See this example with latest code:
$ touch test $ chgrp wheel test $ chmod g+w test $ ls -l test -rw-rw-r-- 1 tobias wheel 0 Mar 31 20:05 test $ ./sort -o test test $ ls -l test -rw-rw-r-- 1 tobias tobias 0 Mar 31 20:05 test It changed group from wheel to tobias, giving that group write access. Tobias