Fix bug writing custom data to wrong files