Revert "Refs #2385 (using a tmp file). In addition, - a better way to get file extensions."

This reverts commit 6e6c16ccaf28d57df3a076c1f8b9b3dbcdc85036.