Use grammar to fix newline issues with buffers