added option for appending newline to data