Improved fix for newline removal