IOException: Sharing violation on path

For some reason I keep getting the error IOException: Sharing violation on path when trying to run SaveScores. This code is meant to load the list of all the scores the player has gotten, adds a score to it, and then saves that. Do any of you know what is wrong with it?

    public void SaveScores(float score){
        List<float> playerScores = LoadScores();

        BinaryFormatter bf = new BinaryFormatter();
        FileStream file = File.Create(Application.persistentDataPath + "/highscores.save");

        Scores scoreClass = new Scores();
        
        playerScores.Add(score);

        scoreClass.scores = playerScores;

        bf.Serialize(file, scoreClass);
        file.Close();

    }

    public List<float> LoadScores(){
        List<float> scores = new List<float>();

        if (File.Exists(Application.persistentDataPath + "/highscores.save"))
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream file = File.Open(Application.persistentDataPath + "/Highscores.save", FileMode.Open);
            
            Scores scoreClass = (Scores)bf.Deserialize(file);
            
            scores = scoreClass.scores;

            file.Close();
        }

        return scores;
    }

could you try adding usings?

using(BinaryFormatter bf = new BinaryFormatter())
{
    using(FileStream file = File.Create(Application.persistentDataPath + "/highscores.save"))
    {           

just in case the garbage collector is not deleting the objects