fixed bug in generateNewFile function