You should add quotes around variables to make sure if there are spaces in there that they get picked up correctly:
#!/bin/bash
for file in /home/user/Desktop/*; do
fileSize=$(stat -c%s "$file")
echo $fileSize
done
What bash does is it simply replaces $var with the thing in $var. If that contains spaces it becomes something else then you intended, because spaces are used in bash to separate command options.
Consider the following example:
file="-l -h -a -F"
ls $file
This gets parsed as:
ls -l -h -a -F
The output will not be the just the file "-l -h -a -F" but it will get parsed as options for ls and it will show the current directory listing. If you had put quotes around $file like so:
file="-l -h -a -F"
ls "$file"
It will get parsed like:
ls "-l -h -a -F"
ls will search for the file "-l -h -a -F" and show only that one file (assuming it exists, it errors otherwise).