NewFile is a Fork from the link.

https://gist.github.com/davejamesmiller/1965432