The quotes around "~ / output" make you sad.
eg
#!/bin/sh file=~/output echo "test" > $file
works fine.
To find out what is going on, try
$ file="~/output" $ echo $file
vs
$ file=~/output $ echo $file
and remember that ~ is a shell extension for the home directory.
source share