Just overwrite the old file with a redirection like echo "" > input.txt
Read input with a prompt can be achieved with read . Else could use positional shell parameters of the shell like $1, $2, ...
For writing input.txt, redirect as said.
Try it, show your efforts. Ask if you get stuck showing your code.
According to your code in post Function is calling only once you should be able to get a start going.