Files are not readable in Swift Playground.
How to make files readable?
Same code runs well on Xcode terminal app, but fails on Swift Playg
You also can create and use Shared Playground Data folder. Just like that:
/Users/username/Documents/Shared Playground Data/file.txt
And any file located there becomes readable to any playground!