`buffer-file-name` could be `nil`, so you need an extra check here.