fixes #4277 this time in pure python (no calls to bash)

Won't this just do 10 and 30 lines? I presume you want 1K and 3K.