Extended iowrite function to support a passed file path