open outfile in write mode