Added new flag: write newline at end