Wait for the port file to be written before trying to use it.