Creating a file then opening it in read write mode is a pretty common operation. This commit adds a helper function that makes it easier to read and clearer.