I think in some scenarios (a lot of times depending on OS), scp behavior interprets directory trailing slashes differently, depending on the situation. This is actually ALWAYS the case with utilities such as rsync, but scp tends to be OS-dependent.
Because of this, if I am using scp in a script to copy a file to a remote directory and want it to retain the original filename, I always add a trailing slash to the directory. I just confirmed that this works:
Cygwin Bash Script:
#!/bin/bash
scp /cygdrive/c/users/jamey/desktop/program.sh 10.0.0.254:/tmp/
Remote Verification:
$ ssh 10.0.0.254
Password:
~/.bash_profile LOADED.
cnu326bxdx:~ Jamey$ ls -l /tmp/program.sh
-rwxr-xr-x 1 Jamey wheel 77 Sep 24 09:51 /tmp/program.sh
Another important thing to note is the permissions on the directory that you are trying to copy to. If your user doesn't have access privileges to the directory you are trying to copy to, the file will obviously not get written. That should be obvious, but sometimes it's the most obvious caveats that create the biggest issues.
One last thing (which I am not a pro on by any means, but am only offering as another possible suggestion) is that if you have spaces in whatever directory your $HOME variable resolves to, that variable could be getting expanded in the shell, which allows the command to work correctly. Alternately, if you do not surround the variable in double-quotes in the script, it may not be getting expanded -- but that would generally cause a visible error, which leads me to believe this particular scenario not to be the case. Either way, you can never go wrong with double-quoting your variables.