while(motivation <= 0)

Back to the blog...
bash vs sh
It's important to note that looping through lines from a variable only works with bash and doesn't work with sh. SH will read lines from a file. bash only feature