Changed the implementation of saveToFile() to get rid of duplicate code.
Re-classified writeFile() to buildString() for future implementation.