title: Why is this python function not reading my json File string properly?
body: <p>So I have a unique player ID string that is stored in a JSON file after it detects on start-up that the player is new to the game.</p>
  <pre><code>def checkIfPlayerIsNew():
  
      if os.path.exists(&quot;myJson.json&quot;):
          print('file exists')
  
          k = open('myPlayerIDs.json')
          print(k.read())
          #print(&quot;This is the k value: {}&quot;.format(code))
          #code = json.dumps(k)
  
          getData(k.read())
  
      else:
          print('file does not exist')
  
          f = open('myJson.json', 'x')  #creates the file if it doesn't exist already
          f.close()
  
          file = open('myPlayerIDs.json', 'w')
          file.write(json.dumps(str(uuid.uuid4())))
          file.close
  
          checkIfPlayerIsNew()
  </code></pre>
  <p><strong>Now,</strong> if it detects that the player is not new it gets the ID from the JSON File and passes it to the get data function below</p>
  <pre><code>def getData(idCode = &quot;X&quot;):
  
      print('the id code is this: {}'.format(idCode))
      outputFile = json.load(open('myJson.json')) 
      for majorkey, subdict in outputFile.items():
          if majorkey == idCode: 
              for subkey, value in subdict.items():
                  print('{} = {}'.format(subkey, value))
                  #playerData[subkey] = value
          else:
              print(&quot;ID Does not match&quot;) 
              break
  </code></pre>
  <p><strong>The problem</strong> is that when I check the id code in the get data function it prints out a blank space as if the id code has been changed to nothing (which I can't figure out why it has done that) and prints this out to the terminal:</p>
  <p><a href="https://i.stack.imgur.com/Yo6Xf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yo6Xf.png" alt="enter image description here" /></a></p>
  <p><strong>The playerID JSON File:</strong></p>
  <p><a href="https://i.stack.imgur.com/FhgMT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FhgMT.png" alt="enter image description here" /></a></p>