file permission flag on open() call was inserted in wrong parameter