add fd as a constructor parameter, and only open file if fd is not present