It turned out that the permission for the dynamics folder was 755, it needed to be 775. After that the 2nd method worked just fine! Thanks for all the help and improvement suggestions! As far as using ">" to open instead of "+>", the page will be changed in some way almost every time this script is called so the whole page has to be re-written.