library(ask)

ask_file(+Prompt, -FileName)
Reads FileName from the terminal, having prompted for it with Prompt. It continues prompting until a FileName is read for which can_open_file(FileName, read, warn) is true, or until an empty line is typed (in the latter case it fails quietly).
ask_file(+Prompt, +Mode, -FileName)
Reads FileName from the terminal, having prompted for it with Prompt. It continues prompting until a FileName is read for which can_open_file(FileName, Mode, warn) is true, or until an empty line is typed (in the latter case it fails quietly).