The correct syntax is this:
while read my_pass do echo $my_pass | sudo -S command done < file_name
Three comments: you cannot use su inside a script file, you will need to use sudo with the -S option which, according to the man,
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.
Second, if you do not like to write the file_name inside the script, use one of the $n arguments, like $1 if it is the only parameter passed.
Third, are you sure collecting all of your passwords in a single, unencrypted file is such a good idea?