Last working version.
increased buffer from 1kb to 512kb.
removed if statement that checks if the command succeeded to remove the newline, this newline needs to be removed ALWAYS.