Sending over UART is NOT recommended, it works much better and smoother over USB. However either way 30 lines of gcode will be consumed immediately, that is the way it works, it HAS to do that becuase it needs to plan the moves and it has a 32 gcode planning buffer without that it would never accelerate up to speed.
If you want to wait until the file is finished before returning the final ok, simply put a M400 at the end of your file. This should also work for the play command from sd card, progress wil not show finished until the M400 is executed.