[Question]
  [
You are given a single printable ASCII string containing no newlines, and a multiline "mold", containing spaces (), and hashes (`#`).
You must go character by character in the string, and replace **hashes** using the characters from the string in left-right, top-bottom order. If the string is too short to fill the mold, you stop outputting, if the string is too long you truncate the string to exactly fill the mold.
---
Example string/mold (string too long, truncated):
```
Loremipsumdolorsitamet,consecteturadipiscingelit.Namsuscipitmagnanoneratgravidacondimentum.Vestibulumnecnisllorem.Fuscemolestieviverranibh,eueleifendnislplaceratnon.Namblanditturpislacus,vitaemolestielacusimperdietquis.Nullapulvinar,exquissollicitudinfacilisis,eratnullavolutpatlectus,etluctusenimvelitegetex.Inhachabitasseplateadictumst.Donecinterdumnullalacinia,sodalesloremin,eleifendturpis.Pellentesqueanisimi.Aeneannonlobortisdiam,quisaliquetquam.Aeneanaugueipsum,imperdietsedaliquetnon,volutpategetsapien.Nullampharetranullaquispretiumornare.Aliquamfermentumvestibulummassavitaevehicula.
###########################################################
##### ##############   ###### ###### ######################
#####  ##   ######   #  ##### ###### ########        ######
###### #  #  ####  #### ##### ###### #######  ######  #####
######   ###  ###       ##### ###### ####### #######  #####
######  ##### ### ########### ###### #######   ###   ######
###### ###### ###  ########## ######      #####   #########
##################       ####    ##########################
###########################################################
```
Example output:
```
Loremipsumdolorsitamet,consecteturadipiscingelit.Namsuscipi
tmagn anoneratgravid   acondi mentum .Vestibulumnecnisllore
m.Fus  ce   molest   i  evive rranib h,euelei        fendni
slplac e  r  atno  n.Na mblan dittur pislacu  s,vita  emole
stiela   cus  imp       erdie tquis. Nullapu lvinar,  exqui
ssolli  citud inf acilisis,er atnull avolutp   atl   ectus,
etluct usenim vel  itegetex.I nhacha      bitas   seplatead
ictumst.Donecinter       dumn    ullalacinia,sodalesloremin
,eleifendturpis.Pellentesqueanisimi.Aeneannonlobortisdiam,q
```
Example string/mold (string too short, output stopped):
```
This probably won't look good.
### ### ### ###
# # # # #   #
### ### #   # #
#   #   #   # #
#   #   ### ###
```
Corresponding output:
```
Thi s p rob abl
y   w o n   '
t l ook     g o
o   d   .   
```
---
Shortest code in bytes wins.
Credit for the idea to [this website](http://jollo.org/ascii2uri.htm).
  
[Answer]
# LabVIEW, 37 [LabVIEW Primitives](http://meta.codegolf.stackexchange.com/a/7589/39490)
splits the string into text and mold then transforms them into an array. Checks the mold if theres a # and puts a char from text else it does nothing. If either the text or the mold are empty exit the loop
[![](https://i.stack.imgur.com/cFBDM.jpg)](https://i.stack.imgur.com/cFBDM.jpg)
[![](https://i.stack.imgur.com/nUHau.gif)](https://i.stack.imgur.com/nUHau.gif)
[Answer]
# Haskell, 48 bytes
called like "(replace with string)#(hashmark string)":
```
[]#_=[]
(r:t)#('#':s)=r:t#s
r#(c:s)=c:r#s
_#_=[]
```
Less golfed:
```
combine replacements slots | null replacements = []
                           | null slots        = []
                           | head slots == '#' = head replacements : combine (tail replacements) (tail slots)
                           | otherwise         = head slots        : combine       replacements  (tail slots)
```
[Answer]
## CJam, ~~16~~ 14 bytes
*Thanks to Sp3000 for saving 2 bytes.*
```
lq{s'#-\+(\}/;
```
Terminates with an error if the string is too short, but the error is printed to STDERR.
[Try it online!](http://cjam.tryitonline.net/#code=bHF7cycjLVwrKFx9Lzs&input=VGhpcyBwcm9iYWJseSB3b24ndCBsb29rIGdvb2QuCiMjIyAjIyMgIyMjICMjIwojICMgIyAjICMgICAjCiMjIyAjIyMgIyAgICMgIwojICAgIyAgICMgICAjICMKIyAgICMgICAjIyMgIyMj)
Alternatively (same byte count):
```
lq{SN+&\+(\}/;
```
### Explanation
```
l       e# Read the input line.
q       e# Read the grid.
{       e# For each character in the grid...
  s     e#   Convert to string.
  '#-   e#   Remove "#" from it.
  \+    e#   Prepend it to the input line (this is a no-op for "#"s in the grid).
  (     e#   Pull off the first character from the input line. This will terminate the
        e#   program with an error once the input line is empty.
  \     e#   Swap the character with the input line.
}/
;       e# Discard the remainder of the input line if there is any.
```
[Answer]
## [Retina](https://github.com/mbuettner/retina/), ~~42~~ 40 bytes
Byte count assumes ISO 8859-1 encoding.
```
T`#`×`¶.+
+`^(.)([^×]+)×
$2$1
^.*¶|×\D*
```
The trailing linefeed is significant.
[Try it online!](http://retina.tryitonline.net/#code=VGAjYMOXYMK2LisKK2BeKC4pKFtew5ddKynDlwokMiQxCl4uKsK2fMOXXEQqCg&input=VGhpcyBwcm9iYWJseSB3b24ndCBsb29rIGdvb2QuCiMjIyAjIyMgIyMjICMjIwojICMgIyAjICMgICAjCiMjIyAjIyMgIyAgICMgIwojICAgIyAgICMgICAjICMKIyAgICMgICAjIyMgIyMj)
### Explanation
```
T`#`×`¶.+
```
We first replace `#` which are part of the grid with the non-ASCII (but extended ASCII) character `×` so we don't confuse them with any `#` that might appear on the first line.
```
+`^(.)([^×]+)×
$2$1
```
Now we fill as many `×` as possible from the first line by repeatedly replacing the first `×` we can find with the first character on the first line (which is removed in the process).
```
^.*¶|×\D*
```
Finally, we get rid of anything that's left on the first line as well as anything from the first `×` to truncate the input in both directions.
[Answer]
# JavaScript (ES6), ~~57~~ ~~56~~ 55 bytes
```
(s,m)=>m.replace(x=/[^]/g,c=>c-1?x&&c:x=s[i++]||"",i=0)
```
*Saved 1 byte thanks to [@Neil](https://codegolf.stackexchange.com/users/17602/neil)!*
## Explanation
Works with hashes in the input string and retains trailing white-space after the input string has finished.
```
var solution =
(s,m)=>
  m.replace(x=/[^]/g,c=> // for each character c of the mold, initialise x to true
    c-1?                 // if c is a space or newline:
      x&&c               // if x is truthy, return c
                         // else if the string has ended, x will equal "" (false), return x
    :                    // else if c is a hash:
      x=                 // set x to the character of the input string
        s[i++]||"",      // return the input string character (or "" if finished)
    i=0                  // initialise i to 0
  )
```
```
<input type="text" id="input" value="This probably won't look good." /><br>
<textarea id="mold" rows="6" cols="40">### ### ### ###
# # # # #   #
### ### #   # #
#   #   #   # #
#   #   ### ###</textarea><br>
<button onclick="result.textContent=solution(input.value,mold.value)">Go</button>
<pre id="result"></pre>
```
[Answer]
# Python 3, ~~69~~ ~~68~~ 67 bytes
```
def f(s,m):s=iter(s);return''.join(n<'#'and n or next(s)for n in m)
```
`[Ideone](http://ideone.com/WDNQ9j)`
Thanks to FryAmTheEggman, Chiel ten Brinke for the byte off. Alternatively, I could have used Python 2 for an extra one (`print` without `()`).
[Answer]
# [pb](https://esolangs.org/wiki/pb), 359 bytes
```
^w[B!0]{w[B=10]{t[T+1]b[0]}>}<w[T!0]{w[B!0]{<}>^b[T]vw[B!0]{t[B]b[0]^v[B]v<[X]w[B!0]{>}b[T]<[X]^[Y+2]w[B=0]{>}t[B]b[0]>b[T]v}^t[B-1]vw[B=0]{<}}>b[10]t[X]w[X!-2]{w[B!0]{v}<}w[X!T]{b[35]>}^[Y]^<[X]w[B!10]{t[B]b[0]w[T=35]{t[10]}v<[X]w[B!35]{w[B=0]{v<[X]<b[1]}>}b[T]^[Y]^<[X]w[B=0]{>}}<[X+2]w[B=0]{v}w[B!0]{b[0]>}w[Y!-1]{<[X]^w[B!0]{w[B=35]{b[0]}w[B=10]{b[35]}>}}
```
In pb, input is strictly one dimensional. It doesn't understand that you're drawing a shape with your input, it just sees one long line with some bytes with a value of 10 thrown in there. The first thing this program does is copy all but the first "line" of input onto Y=0, Y=1, etc, to create the shape of the mold.
Something I've noticed a lot in code golf, but *especially* when golfing esoteric languages, is that you often don't want to have two branches to deal with; you just set yourself up that you do the same thing in either case. The naive way to solve this problem would probably check the length of the string against the number of hashes in the rest of the input and do something depending on the result, because it has to behave differently depending on what gets cut off. But that's a lot of bytes.
Instead, after completing the mold, an extra line is added to the bottom. It is simply `n` hashes in a row, where `n` is the length of the string. Now the string is guaranteed to fit! After inserting all the characters of the string, that extra line that was added is unconditionally destroyed. Any leftover hashes in the mold proper are erased as well, and that's the necessary output!
Of course, it would violate the spec to simply destroy all hashes. After all, there could be a hash in the input string! To handle this, I refer to another part of the spec:
> 
> You are given a single printable ASCII string **containing no newlines**
> 
> 
> 
(Emphasis mine.) By the time we're dealing with the string, we don't really care if there are newlines in it, but we do know that there aren't any. So, all hashes are replaced with newlines before being put into the mold! After all hashes are destroyed, all newlines are replaced with hashes again. This doesn't turn the entire output into a single hash-delimited line because the nature of pb's 2D output means that it never actually put a newline at the end of each line, it just went on to the next line.
**Ungolfed:**
```
# Start by copying down the mold
^
# (B means "the character under the cursor")
w[B!0]{       # While B isn't a null byte:
    w[B=10]{    # While B IS a newline:
            t[T+1]    # Increase T by 1
                      # (`T` is the only variable that can be modified directly)
            b[0]      # Overwrite with 0 to break out of inner loop
    }
    >           # Move to the right
                # (dodge the 0 we wrote and progress towards the end of input)
}
# Brush is now at the end of the input, T contains number of lines
<             # Make sure the brush is actually /on/ the input
w[T!0]{       # While T isn't 0:
    w[B!0]{<}>  # Go to the first character of the last line
    ^b[T]       # Place a flag above current character
                # Also a convenient way to get the value of T back later
    vw[B!0]{    # While the character under the flag isn't 0:
            t[B]b[0]  # Put it in T, overwrite with 0
            ^v[B]v    # Go down by the amount written in the space above
            <[X]      # Go left by the amount right the brush is (i.e. go to X=0)
            w[B!0]{>} # Find first empty space
            b[T]      # Write the value of T
            <[X]      # Go left by the amount right the brush is
            ^[Y+2]    # Go up by the amount down the brush is plus 2 (above input)
            w[B=0]{>} # Find flag
            t[B]b[0]  # Pick it up, overwrite with 0
            >b[T]     # Place it to the right
    v}
    ^t[B-1]v    # Collect flag - 1
    w[B=0]{<}   # Go to end of previous line
}
# Mold is placed, all that's left is placing the string
>b[10]        # Put a newline at the end, guaranteed to not be in the string
t[X]          # Save current X value in T
# Add more hashes, guaranteed to fit the input and findable later
w[X!-2]{       # While X!=-2:
    w[B!0]{v}    # Move down until hitting a null byte
    <            # Move left
}
w[X!T]{        # While not at the X value we saved earlier:
    b[35]>       # Travel right, leaving hashes
}
^[Y]^<[X]     # Go to (0, -1)
w[B!10]{      # Until hitting the newline at the end:
    t[B]b[0]    # Pick up character, overwrite with 0
    w[T=35]{    # If it's a hash...
            t[10]     # Make it a newline so we remember, deal with it later
    }
    v<[X]       # Go to (0, 0)
    w[B!35]{    # While B is not a hash:
            w[B=0]{   # While B IS null:
                    v       # Go down
                    <[X]<   # Go to X=-1
                    b[1]    # Print a 1 to break loop (it won't be rendered anyway)
            }
            >           # Go right, either ignore a non hash or go to X=0
    }
    b[T]        # Overwrite hash with picked up character
    ^[Y]^<[X]   # Go to (0, -1)
    w[B=0]{>}   # Go to first character of it to restart loop
}
<[X+2]        # Go to (-2, -1)
w[B=0]{v}     # Go down until finding the row of added hashes
w[B!0]{b[0]>} # Wipe it out unconditionally
w[Y!-1]{      # For every remaining line on the screen:
    <[X]^       # Go to the beginning
    w[B!0]{     # For each character in it:
            w[B=35]{  # If it's a hash:
                    b[0]    # Destroy it
            }
            w[B=10]{  # If it's a newline:
                    b[35]   # Write a hash (after the check to destroy hashes!)
            }
    >}
}
```
[Answer]
## ES6, 59 bytes
```
(t,m)=>m.replace(/#/g,h=>t[i++]||h,i=0).replace(/#[^]*/,'')
```
70 bytes if the text can contain hashes:
```
(t,m)=>m.replace(/#/g,(_,n)=>t[i]&&(j=++n)&&t[i++],i=0,j=0).slice(0,j)
```
[Answer]
## Perl, ~~53~~ ~~51~~ 42 + 2 = 44 bytes
```
@a=/./g;$/="";$_=<>;s/#/shift@a/ge;s/\s+$//
```
Requires `-p` to run. Explanation:
```
@a=/./g; # Split first line into an array of characters
$/=""; # Enable slurp mode (read the rest of lines in one go)
$_=<>;
s/#/shift@a/ge;
s/\s+$//
# With '-p' auto print is enabled
```
[Answer]
# Jelly, ~~10~~ 8 bytes
```
¹ƈ<”#$?€
```
[Try it here!](http://jelly.tryitonline.net/#code=wrnGiDzigJ0jJD_igqw&input=TG9yZW1pcHN1bWRvbG9yc2l0YW1ldCxjb25zZWN0ZXR1cmFkaXBpc2NpbmdlbGl0Lk5hbXN1c2NpcGl0bWFnbmFub25lcmF0Z3JhdmlkYWNvbmRpbWVudHVtLlZlc3RpYnVsdW1uZWNuaXNsbG9yZW0uRnVzY2Vtb2xlc3RpZXZpdmVycmFuaWJoLGV1ZWxlaWZlbmRuaXNscGxhY2VyYXRub24uTmFtYmxhbmRpdHR1cnBpc2xhY3VzLHZpdGFlbW9sZXN0aWVsYWN1c2ltcGVyZGlldHF1aXMuTnVsbGFwdWx2aW5hcixleHF1aXNzb2xsaWNpdHVkaW5mYWNpbGlzaXMsZXJhdG51bGxhdm9sdXRwYXRsZWN0dXMsZXRsdWN0dXNlbmltdmVsaXRlZ2V0ZXguSW5oYWNoYWJpdGFzc2VwbGF0ZWFkaWN0dW1zdC5Eb25lY2ludGVyZHVtbnVsbGFsYWNpbmlhLHNvZGFsZXNsb3JlbWluLGVsZWlmZW5kdHVycGlzLlBlbGxlbnRlc3F1ZWFuaXNpbWkuQWVuZWFubm9ubG9ib3J0aXNkaWFtLHF1aXNhbGlxdWV0cXVhbS5BZW5lYW5hdWd1ZWlwc3VtLGltcGVyZGlldHNlZGFsaXF1ZXRub24sdm9sdXRwYXRlZ2V0c2FwaWVuLk51bGxhbXBoYXJldHJhbnVsbGFxdWlzcHJldGl1bW9ybmFyZS5BbGlxdWFtZmVybWVudHVtdmVzdGlidWx1bW1hc3Nhdml0YWV2ZWhpY3VsYS4&args=IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMKIyMjIyMgIyMjIyMjIyMjIyMjIyMgICAjIyMjIyMgIyMjIyMjICMjIyMjIyMjIyMjIyMjIyMjIyMjIyMKIyMjIyMgICMjICAgIyMjIyMjICAgIyAgIyMjIyMgIyMjIyMjICMjIyMjIyMjICAgICAgICAjIyMjIyMKIyMjIyMjICMgICMgICMjIyMgICMjIyMgIyMjIyMgIyMjIyMjICMjIyMjIyMgICMjIyMjIyAgIyMjIyMKIyMjIyMjICAgIyMjICAjIyMgICAgICAgIyMjIyMgIyMjIyMjICMjIyMjIyMgIyMjIyMjIyAgIyMjIyMKIyMjIyMjICAjIyMjIyAjIyMgIyMjIyMjIyMjIyMgIyMjIyMjICMjIyMjIyMgICAjIyMgICAjIyMjIyMKIyMjIyMjICMjIyMjIyAjIyMgICMjIyMjIyMjIyMgIyMjIyMjICAgICAgIyMjIyMgICAjIyMjIyMjIyMKIyMjIyMjIyMjIyMjIyMjIyMjICAgICAgICMjIyMgICAgIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMKIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyM)
[Answer]
# [Perl 6](http://perl6.org), 72 bytes
```
my@a=get.comb;say(S:g/\#/{@a.shift//''}/~~{S/\s+$//}),@a||last for lines
```
[Answer]
# ES6, 47 bytes
Probably the most straightforward solution.
```
(S,R)=>(i=-1,S.replace(/#/g,_=>R[++i]||R[i=0]))
```
This code creates an anonymous function that receives 2 parameters and returns the final result.
The first parameter `S` is the "map" string with your `"#"`, while the second parameter `R` is the "replacement" for those `"#"`.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 52 bytes
```
->a,b{i=-1
a.gsub(/(#)|./){b[i+1]?$1?b[i+=1]:$&:""}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=nVTNatwwEL705KcQu6FNqOOw0EMJpCFQAoUSeii9hBzG9qx36Ehy9OMmpHmSXkJJH6p9lJ46sp2Nk02hVIvl-ftm5ht59e3WxfLy5vvxwY8Ylruvf77afQN5eUUHu4sMisbHcntve77ztdjbuSpP6eXi7HBrcZikg8XZ_tbz_dns-nrA_nr2u43Bq-PT2fz_V9bv6qFRqdHw8PUXrJoCRBjlx1g1ril23kcPtnF_Cnuf_QG2V8ftPvVj7Pxp7No5JbdRV80n5LKNIKU2sZNOJu5svrEmTatp6MZ6AvvPa5Zns_fWoabWR11bts5TAI0hr6zxWAUM0UFNLfmKTINMoTgB7aOoLQUNjQFjDToIjYOOahBcTRpNiLr4hD5QGTlqg5Uhz5xqFceCRm05ebGjDp0DQ-Uqx4iMtERTp-CWoUqJJX-qWTJI5iD9SDPiij7vpNd1ot5EukVXE4bzSL44iczQRu7IgMvxIhm9ZaaKQqzJLKEiJk8-7-uk6M5yDC0EFu5SAQPHJKAh3SX22GDAi-KdWUG1glIa8B6l04AyJYnUPhRvZSAyrSCdCPOUVXojQ5B7W4N024-BTH7HduBUfEBmGRz684gyECFDxREakWUEbEvrAvmaQOeJCDBJnBAFPUZBbCL2J5mv5-CxHgMlR37HLrHw0BKaYUa6XYHDIMeQtJS9FZWitk4mh8VRSgF6iW442W59sFr4Q38OHa6oigzF7CxLV0-WTS4gNXmy9L8efvJdZ2tPfzskr1L3z0Qf4tIn-3FFXrXOllDypfpizYug2NrPqrG2lvrDFXhzM7z_AA)
[Answer]
# [Julia 1.0](http://julialang.org/), ~~98 88~~ 77 bytes
```
!S=((a,b)=split(S,'
';limit=2);j=0;[b...].|>m->(print(m=='#' ? a[j+=1] : m)))
```
[Try it online!](https://tio.run/##nVNNb9swDL37V6jNIQnmCeuOK9yhwDBgwFAMyLDL0ANtszE7SnL14bXA/ntGOWniItkOVRBblPio9x6t@8QEF4@bzdmqWiygrJdV6JniYlXOi/klk6FYvV9e3lfvLn/WWutb/efKvL1a9J5sXJiqms/m6qOCn/dvqotb9UGZ5XK5WVXn3zsKqveuhpqf1G9n51Gxc7/U2rlWF7PZTE3@hTx3P6Vmh90c5Xh8q@N4m3deFNE/FUqdrYoGYtPJdCTIdrEs0LZFIYy@Oo@G@pBM69j5QBEMxrJxNmATMSYPLfUUGrJrFA/0DZiQJOwpGlhbsM6ih7j2MFALgmvJoI3J6B8YItWJk7HYWArM@Sz9WdBoHOddHGhA78FS3ZWYkJHuhFlO7hmaXFjq5zNrBqkchY@Qka0UykG47guNS2R69C1hfEgU9E1ihj7xQBZ8iY95MThmaiimluwdNMQUKJTjOTl7cJxiD5FFu5yAkVOeoCUzZPW4xoiP@ovtoOmgFgIhoDCNKC5JpglRfxJDxK0oTER5rircyBKUwbUgbEcbyJbParea9DdkFuMwPCQUQ0QM6Wu0MhcL2NXORwotgSmzEGCSPBEKZpcFaZ1w7GS59yFgu0uUGuWzuqwiQE9otx6ZvgOPUdqQo1y9l5CScV6cQ32dS4C5Q7/t7LBvrBH9MPZhwI6axDB@xK8dW6x6ubj9og/r6r9YNQWM9@EkVu3GFDverB1g9zyFPVR/gd3eO3WofRI7O43db07FHZ2rpm4UR0lKHWMnTCbbJ3o0Ia2mqf/w@XXjvDhbbf4C "Julia 1.0 – Try It Online")
-22 MarcMush
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 39 bytes
```
{(w@l)#@[y;l#w;:;(l:(#x)&#w:&"#"=y)#x]}
```
[Try it online!](https://ngn.codeberg.page/k#eJydVNtq20AQfddXLBIkNgilfXUIOFAKhRL6UPrSlHYkje2hs7vKXmSb0n/vrKw4cpyU0jXS3uacOWdGeLX4NdsueV4sv+6vudheL65nvJgVu/lFsV1c5EV+s58Xu2+/swwWs/yjdaip81G3lq3zFEBjKBtrPDYBQ3TQUke+IbNGplDdgfZRth0FDWsDxhp0ENYOempBcC1pNCHq6gv6QHXkqA02hjxzylW9FzRqy+kWe+rROTBUb0qMyEgrNG0K7hiaRCz8KWfNIMxB9IgYuYq+7EXrkWg4It2hawnDQyRf3UVm6CL3ZMCVuEuH3jJTQyG2ZFbQEJMnXw55UnRvOYYOAot3yYCBY1qgId0n97jGgLvqg9lAs4FaBHiPojSgVEkitQ/VOymIVCuIEnGeWEUbGYLS2xZE7VAGMuWj24On6hMyS+HQP0SUgogZqm7RyFpKwLa2LpBvCXSZjACTxIlR0GMUxHXEoZPlsQ4e2zFQOMpHd8mFh47QHGqkuw04DNKGtEvsnWwpauukcljdJgrQK3SHzvbHxmrxD0MfetxQExmqPFP5vcmv3n6/TPN9ror/H9kB/IxCqfHgdHoNrKYIWagT0iNYjeMEXAzhh8Px/RL4if4UPOzH1xP5c3DxCvh4OzV4llkVE3+ZOotS6hw80TK5zqZ5immoelyeB/wN/M8jn2dZLf9GnzfkVedsDTXv1daay6DY2p9qbW378qc1fUTD8Sdas6e7oe/DvZo804NDZBLy481itbyCNOf5uKuzP+zla0U=)
Explanation:
```
{(w@l)#                                 / up to the final index
       @[y;                             / replace the mold
           l#w;:;                       / at the first l indices of hash characters
                 (l:(#x)&#w:&"#"=y)     / where l is the min of
                                          number of such indices and length of string
                                   #x]} / with the first l characters of string
```
Uses the fact that one past the last index of a list is null and taking the first null characters defaults to the full list.
[Answer]
# Python 3
# ~~152~~ 127 bytes
A full program.
```
from sys import stdin as S
s=list(S.readline())
print(''.join([''if not s else(s.pop(0)if m=='#'else m)for m in S.read()]))
```
# 106 bytes
A function that takes the stream as input.
```
def f(S):s=list(S.readline());return''.join([''if not s else(s.pop(0)if m=='#'else m)for m in S.read()])
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
`'ÿ«)'#s.;'ÿ¡н
```
Also complies to the two rules in the comments, unlike some of the other answers:
1. The input-sentence can contain hashes and (potentially trailing) spaces.
2. The output does not contain trailing spaces (unless the input contained trailing spaces), only a single trailing newline.
[Try it online.](https://tio.run/##yy9OTMpM/f8/Qf3w/kOrNdWVi/WsQcyFF/b@/x@SkVmsUFCUn5SYlFOpUJ6fp16ikJOfn62Qnp@foselpKSkrKysgIS5gCQUKigAeTAZEA/EB9MKmHyIOqB5AA)
**Explanation:**
I take advantage of the fact that the input only contains printable ASCII.
```
`               # Push the characters of the first (implicit) input-sentence separately
                # to the stack
 'ÿ«           '# Append an "ÿ" to the last character
    )           # Wrap the entire stack into a list
     '#        '# Push string "#"
       s        # Swap so the list is at the top again
        .;      # Replace every first "#" in the second (implicit) multi-line string
                # with the items in the list one by one
          'ÿ¡  '# Split the resulting string on "ÿ"
             н  # Only keep the first part
                # (after which the result is output implicitly with trailing newline)
```
Unfortunately [the legacy version of 05AB1E](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b) doesn't vectorize with builtin `.;`, otherwise the second `'ÿ` could have been replaced with `Z` (maximum character - based on codepoint - without popping). In the new 05AB1E version, the min/max builtins doesn't work on characters. But because it doesn't vectorize, it's 15 bytes instead: [``'ÿ«)v'#y.;}Z¡н` - try it online](https://tio.run/##MzBNTDJM/f8/Qf3w/kOrNcvUlSv1rGujDi28sPf//5CMzGKFgqL8pMSknEqF8vw89RKFnPz8bIX0/PwUPS4lJSVlZWUFJMwFJKFQQQHIg8mAeCA@mFbA5EPUAc0DAA).
[Answer]
# [Python](https://www.python.org), 64 bytes
```
f=lambda s,m:m and(z:=m[0]*(m[0]!='#')+s)and z[0]+f(z[1:],m[1:])
```
[Attempt This Online!](https://ato.pxeger.com/run?1=pVTNbtQwED5x2acwu4fu0hDRPaFKK1EJISGhigPiUvUwiSebEf6rf0LbV-HSC7wTPE3HSbqbdssFHMXx_Hzj-WYc__jlbmJrzd3dzxSb129_v2s2CnQlQYRCn2oBRi5vTzf64s3lq2WeX26OFker47Bii7hlxXGzvL04Ob0sdJ5XQ5w_L5bhRGzE_JP1qMmFpKVV1geKoDEWtTUB64gxeZDkKNRktqgoluegQ2LRUdSwNWCsQQ9x66EjCYyTpNHEpMuvGCJVSSVtsDYUlMp7lR8YjdqqbMWOOvQeDFVtgQkVUoNGZmenoM6BOX7es1LMhyLnw8mwKYWi41x3gXoVaYdeEsarRKE8T0qBS6ojA77A66wMVimqKSZJpoGaFAUKRb9P9u6sStFBVMydd8CoUl6gId1l9rjFiNflR9NC3ULFCYSAnGlErhJ76hDL91wQrlbkTJh5jsq5kSEogpXA2fZlIFM8sB04lZ9RKS4chquEXBAmQ-UZGl5zCZStrI8UJIEuMhFQxH5MFPToBWmbsO9ksatDQDk6cozigV1mEcARmqFG2rXgMXIbspSjOxYpaeu5clie5RCgG_RDZ7tdYzXzh74PHbZUJwXlfKb7gzWfzxb_PgaseKwUYlQ8_vwFK6YAXozrp1gxjil20XsPunF-DruP_gjbi-O0D_0Uu3geuzNOyR3sKxYTcrMDJyEOsZNMJuZnejRJWkxdD8Z_9Tefj1lY55PypaUgnLcVVOpGfLfmKApl7TextVbm87TenycxeWe5TcPTd2tv7-VsF2L_TuQR3-fgPP-ry4avw0Lok9Vqr1izYr0aL8yHC_ge)
]